From 7580a9a2913f32b5fdf0af5622e7d745c186531c Mon Sep 17 00:00:00 2001 From: Javier Calvarro Nelson Date: Thu, 8 May 2014 11:36:44 -0700 Subject: [PATCH] Changed the default status code of ResponseInformation to 200 in order to be consistent with the behavior of the rest of the hosts. --- .../Microsoft.AspNet.TestHost.kproj | 1 + .../Properties/AssemblyInfo.cs | 38 +++++++++++++++++++ .../ResponseInformation.cs | 4 ++ .../Microsoft.AspNet.TestHost.Tests.kproj | 2 + .../Properties/AssemblyInfo.cs | 36 ++++++++++++++++++ .../ResponseInformationTests.cs | 34 +++++++++++++++++ 6 files changed, 115 insertions(+) create mode 100644 src/Microsoft.AspNet.TestHost/Properties/AssemblyInfo.cs create mode 100644 test/Microsoft.AspNet.TestHost.Tests/Properties/AssemblyInfo.cs create mode 100644 test/Microsoft.AspNet.TestHost.Tests/ResponseInformationTests.cs diff --git a/src/Microsoft.AspNet.TestHost/Microsoft.AspNet.TestHost.kproj b/src/Microsoft.AspNet.TestHost/Microsoft.AspNet.TestHost.kproj index b0b2425081..0711ff81b0 100644 --- a/src/Microsoft.AspNet.TestHost/Microsoft.AspNet.TestHost.kproj +++ b/src/Microsoft.AspNet.TestHost/Microsoft.AspNet.TestHost.kproj @@ -20,6 +20,7 @@ + diff --git a/src/Microsoft.AspNet.TestHost/Properties/AssemblyInfo.cs b/src/Microsoft.AspNet.TestHost/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..5eb8f1ffac --- /dev/null +++ b/src/Microsoft.AspNet.TestHost/Properties/AssemblyInfo.cs @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Open Technologies, Inc. +// All Rights Reserved +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR +// CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING +// WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF +// TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR +// NON-INFRINGEMENT. +// See the Apache 2 License for the specific language governing +// permissions and limitations under the License. + +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Microsoft.AspNet.TestHost")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyProduct("Microsoft.AspNet.TestHost")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("12A3EDBB-65B6-4D47-98FC-2B80CEC71E51")] + +[assembly: InternalsVisibleTo("Microsoft.AspNet.TestHost.Tests")] \ No newline at end of file diff --git a/src/Microsoft.AspNet.TestHost/ResponseInformation.cs b/src/Microsoft.AspNet.TestHost/ResponseInformation.cs index 9a8f672817..7cccbafc53 100644 --- a/src/Microsoft.AspNet.TestHost/ResponseInformation.cs +++ b/src/Microsoft.AspNet.TestHost/ResponseInformation.cs @@ -28,6 +28,10 @@ namespace Microsoft.AspNet.TestHost { Headers = new Dictionary(StringComparer.OrdinalIgnoreCase); Body = new MemoryStream(); + + // 200 is the default status code all the way down to the host, so we set it + // here to be consistent with the rest of the hosts when writing tests. + StatusCode = 200; } public int StatusCode { get; set; } diff --git a/test/Microsoft.AspNet.TestHost.Tests/Microsoft.AspNet.TestHost.Tests.kproj b/test/Microsoft.AspNet.TestHost.Tests/Microsoft.AspNet.TestHost.Tests.kproj index 4deca87e2d..cb04e9bc60 100644 --- a/test/Microsoft.AspNet.TestHost.Tests/Microsoft.AspNet.TestHost.Tests.kproj +++ b/test/Microsoft.AspNet.TestHost.Tests/Microsoft.AspNet.TestHost.Tests.kproj @@ -21,6 +21,8 @@ + + diff --git a/test/Microsoft.AspNet.TestHost.Tests/Properties/AssemblyInfo.cs b/test/Microsoft.AspNet.TestHost.Tests/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..64d1e18c97 --- /dev/null +++ b/test/Microsoft.AspNet.TestHost.Tests/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Open Technologies, Inc. +// All Rights Reserved +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR +// CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING +// WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF +// TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR +// NON-INFRINGEMENT. +// See the Apache 2 License for the specific language governing +// permissions and limitations under the License. + +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Microsoft.AspNet.TestHost.Tests")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyProduct("Microsoft.AspNet.TestHost.Tests")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("82F61927-58D7-465C-9100-92D202FEA300")] \ No newline at end of file diff --git a/test/Microsoft.AspNet.TestHost.Tests/ResponseInformationTests.cs b/test/Microsoft.AspNet.TestHost.Tests/ResponseInformationTests.cs new file mode 100644 index 0000000000..1717152773 --- /dev/null +++ b/test/Microsoft.AspNet.TestHost.Tests/ResponseInformationTests.cs @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Open Technologies, Inc. +// All Rights Reserved +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR +// CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING +// WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF +// TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR +// NON-INFRINGEMENT. +// See the Apache 2 License for the specific language governing +// permissions and limitations under the License. + +using Xunit; + +namespace Microsoft.AspNet.TestHost.Tests +{ + public class ResponseInformationTests + { + [Fact] + public void StatusCode_DefaultsTo200() + { + // Arrange & Act + var responseInformation = new ResponseInformation(); + + // Assert + Assert.Equal(200, responseInformation.StatusCode); + } + } +} \ No newline at end of file