diff --git a/src/Stellar.Tests/Properties/AssemblyInfo.cs b/src/Stellar.Tests/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..76f10e3 --- /dev/null +++ b/src/Stellar.Tests/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +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("Stellar.Tests")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Stellar.Tests")] +[assembly: AssemblyCopyright("Copyright © 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 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("4335f266-3f71-4349-b926-d233307fc2f6")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/Stellar.Tests/SimpleQueryTest.cs b/src/Stellar.Tests/SimpleQueryTest.cs new file mode 100644 index 0000000..8ffb79b --- /dev/null +++ b/src/Stellar.Tests/SimpleQueryTest.cs @@ -0,0 +1,22 @@ +using Stellar; +using Xunit; + +namespace Tests +{ + public class SimpleQueryTest + { + private CosmosDbAccount BogusCosmosDbAccount => new Stellar.CosmosDbAccount(@"http://www.bogusendpoint.com", "bogustoken", "bogusdb", ""); + + [Fact] + public void SimpleQueryShouldIncludeSelectAndType() + { + var testObjectsQueryAsString = BogusCosmosDbAccount.Documents.Query().ToString().ToLower(); + + Assert.Contains("select", testObjectsQueryAsString); + Assert.Contains("*", testObjectsQueryAsString); + Assert.Contains("from", testObjectsQueryAsString); + Assert.Contains(typeof(TestObject).Name.ToString().ToLower(), testObjectsQueryAsString); + Assert.Contains("as", testObjectsQueryAsString); + } + } +} diff --git a/src/Stellar.Tests/SimpleQueryWithWhere.cs b/src/Stellar.Tests/SimpleQueryWithWhere.cs new file mode 100644 index 0000000..24e38e3 --- /dev/null +++ b/src/Stellar.Tests/SimpleQueryWithWhere.cs @@ -0,0 +1,45 @@ +using System.Linq; +using Tests; +using Xunit; + +namespace Stellar.Tests +{ + public class SimpleQueryWithWhere + { + private CosmosDbAccount BogusCosmosDbAccount => new Stellar.CosmosDbAccount(@"http://www.bogusendpoint.com", "bogustoken", "bogusdb", ""); + + private const int testValue = 20; + + [Fact] + public void WhereClauseShouldIncludeTestCondition() + { + var testObjectsQueryAsString = BogusCosmosDbAccount.Documents.Query() + .Where(x => x.SomeIntProperty == 20) + .ToString().ToLower(); + + Assert.Contains("where", testObjectsQueryAsString); + Assert.Contains("someintproperty", testObjectsQueryAsString); + Assert.Contains("20", testObjectsQueryAsString); + } + + [Fact] + public void WhereClauseShouldIncludeTestValueWhetherLiteralOrFromAVariable() + { + var testObjectsQueryAsString = BogusCosmosDbAccount.Documents.Query() + .Where(x => x.SomeIntProperty == 20) + .ToString().ToLower(); + + Assert.Contains("where", testObjectsQueryAsString); + Assert.Contains("someintproperty", testObjectsQueryAsString); + Assert.Contains(testValue.ToString(), testObjectsQueryAsString); + + var testObjectsQueryWithVariableAsString = BogusCosmosDbAccount.Documents.Query() + .Where(x => x.SomeIntProperty == testValue) + .ToString().ToLower(); + + Assert.Contains("where", testObjectsQueryWithVariableAsString); + Assert.Contains("someintproperty", testObjectsQueryWithVariableAsString); + Assert.Contains(testValue.ToString(), testObjectsQueryWithVariableAsString); + } + } +} diff --git a/src/Stellar.Tests/Stellar.Tests.csproj b/src/Stellar.Tests/Stellar.Tests.csproj new file mode 100644 index 0000000..f13fa89 --- /dev/null +++ b/src/Stellar.Tests/Stellar.Tests.csproj @@ -0,0 +1,89 @@ + + + + + + + Debug + AnyCPU + {4335F266-3F71-4349-B926-D233307FC2F6} + Library + Properties + Stellar.Tests + Stellar.Tests + v4.6.1 + 512 + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + ..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll + + + ..\packages\xunit.assert.2.3.1\lib\netstandard1.1\xunit.assert.dll + + + ..\packages\xunit.extensibility.core.2.3.1\lib\netstandard1.1\xunit.core.dll + + + ..\packages\xunit.extensibility.execution.2.3.1\lib\net452\xunit.execution.desktop.dll + + + + + + + + + + + + + + + + + {fbc836b1-b067-412c-914d-17f205f7cce7} + Stellar + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + \ No newline at end of file diff --git a/src/Stellar.Tests/TestObject.cs b/src/Stellar.Tests/TestObject.cs new file mode 100644 index 0000000..a21a31a --- /dev/null +++ b/src/Stellar.Tests/TestObject.cs @@ -0,0 +1,8 @@ +namespace Tests +{ + public class TestObject + { + public string Name { get; set; } + public int SomeIntProperty { get; set; } + } +} diff --git a/src/Stellar.Tests/packages.config b/src/Stellar.Tests/packages.config new file mode 100644 index 0000000..662797c --- /dev/null +++ b/src/Stellar.Tests/packages.config @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/Stellar.sln b/src/Stellar.sln index 2bf7cd9..d2c0ae0 100644 --- a/src/Stellar.sln +++ b/src/Stellar.sln @@ -6,6 +6,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Stellar", "stellar\Stellar. EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Stellar.Samples", "Stellar.Samples\Stellar.Samples.csproj", "{8C6C4AA9-4D96-4F5E-B841-3D7195F68F9D}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Stellar.Tests", "Stellar.Tests\Stellar.Tests.csproj", "{4335F266-3F71-4349-B926-D233307FC2F6}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -40,6 +42,18 @@ Global {8C6C4AA9-4D96-4F5E-B841-3D7195F68F9D}.Release|x64.Build.0 = Release|Any CPU {8C6C4AA9-4D96-4F5E-B841-3D7195F68F9D}.Release|x86.ActiveCfg = Release|Any CPU {8C6C4AA9-4D96-4F5E-B841-3D7195F68F9D}.Release|x86.Build.0 = Release|Any CPU + {4335F266-3F71-4349-B926-D233307FC2F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4335F266-3F71-4349-B926-D233307FC2F6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4335F266-3F71-4349-B926-D233307FC2F6}.Debug|x64.ActiveCfg = Debug|Any CPU + {4335F266-3F71-4349-B926-D233307FC2F6}.Debug|x64.Build.0 = Debug|Any CPU + {4335F266-3F71-4349-B926-D233307FC2F6}.Debug|x86.ActiveCfg = Debug|Any CPU + {4335F266-3F71-4349-B926-D233307FC2F6}.Debug|x86.Build.0 = Debug|Any CPU + {4335F266-3F71-4349-B926-D233307FC2F6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4335F266-3F71-4349-B926-D233307FC2F6}.Release|Any CPU.Build.0 = Release|Any CPU + {4335F266-3F71-4349-B926-D233307FC2F6}.Release|x64.ActiveCfg = Release|Any CPU + {4335F266-3F71-4349-B926-D233307FC2F6}.Release|x64.Build.0 = Release|Any CPU + {4335F266-3F71-4349-B926-D233307FC2F6}.Release|x86.ActiveCfg = Release|Any CPU + {4335F266-3F71-4349-B926-D233307FC2F6}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE