diff options
Diffstat (limited to 'Software/Visual_Studio_v2/Tango.UnitTests')
| -rw-r--r-- | Software/Visual_Studio_v2/Tango.UnitTests/BLL/Services/OrganizationsService_TST.cs | 63 | ||||
| -rw-r--r-- | Software/Visual_Studio_v2/Tango.UnitTests/DAL/MongoRepository_TST.cs (renamed from Software/Visual_Studio_v2/Tango.UnitTests/DAL/Mongo.cs) | 12 | ||||
| -rw-r--r-- | Software/Visual_Studio_v2/Tango.UnitTests/Tango.UnitTests.csproj | 7 |
3 files changed, 78 insertions, 4 deletions
diff --git a/Software/Visual_Studio_v2/Tango.UnitTests/BLL/Services/OrganizationsService_TST.cs b/Software/Visual_Studio_v2/Tango.UnitTests/BLL/Services/OrganizationsService_TST.cs new file mode 100644 index 000000000..4db1af5c4 --- /dev/null +++ b/Software/Visual_Studio_v2/Tango.UnitTests/BLL/Services/OrganizationsService_TST.cs @@ -0,0 +1,63 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BLL.Objects; +using Tango.BLL.Services; +using Tango.DAL.Entities; +using Tango.DAL.Mongo; + +namespace Tango.UnitTests.BLL.Services +{ + [TestClass] + [TestCategory("BLL.OrganizationsService")] + public class OrganizationsService_TST + { + [TestMethod] + public void Simple_Operations() + { + OrganizationsService service = new OrganizationsService(new MongoRepository<OrganizationEntity>(new MongoDataBaseSettings() + { + Address = "mongodb://localhost:27017", + DatabaseName = "TEST" + })); + + service.DeleteAllOrganizations().GetAwaiter().GetResult(); + + Organization org1 = new Organization(); + org1.Name = "Org 1"; + org1.Address.AddressString = "Yohana 7 a"; + org1.Address.City = "Gan Yavne"; + org1.Address.State = "Israel"; + org1.Contact.Email = "roy@twine-s.com"; + org1.Contact.FirstName = "Roy"; + org1.Contact.LastName = "Ben Shabat"; + + service.AddOrganization(org1).GetAwaiter().GetResult(); + + Assert.IsNotNull(org1.ID); + + Organization orgDuplicate = new Organization(); + orgDuplicate.Name = org1.Name; + + Assert.ThrowsException<MongoDB.Driver.MongoWriteException>(() => + { + service.AddOrganization(orgDuplicate).GetAwaiter().GetResult(); + }); + + var org2 = service.GetOrganizationByID(org1.ID).GetAwaiter().GetResult(); + + Assert.AreEqual(org1.Name, org2.Name); + + long count = service.DeleteOrganizationByID(org1.ID).GetAwaiter().GetResult(); + + Assert.AreEqual(count, 1); + + count = service.Count().GetAwaiter().GetResult(); + + Assert.AreEqual(count, 0); + } + } +} diff --git a/Software/Visual_Studio_v2/Tango.UnitTests/DAL/Mongo.cs b/Software/Visual_Studio_v2/Tango.UnitTests/DAL/MongoRepository_TST.cs index d15b1c7a9..709a9c733 100644 --- a/Software/Visual_Studio_v2/Tango.UnitTests/DAL/Mongo.cs +++ b/Software/Visual_Studio_v2/Tango.UnitTests/DAL/MongoRepository_TST.cs @@ -7,7 +7,7 @@ using System.Linq; namespace Tango.UnitTests.DAL { [TestClass] - public class Mongo + public class MongoRepository_TST { [TestMethod] public void Simple_Operations() @@ -22,9 +22,17 @@ namespace Tango.UnitTests.DAL OrganizationEntity org1 = new OrganizationEntity(); org1.Name = "Org 1"; + org1.Address.AddressString = "Yohana 7 a"; + org1.Address.City = "Gan Yavne"; + org1.Address.State = "Israel"; + org1.Contact.Email = "roy@twine-s.com"; + org1.Contact.FirstName = "Roy"; + org1.Contact.LastName = "Ben Shabat"; repo.Insert(org1).GetAwaiter().GetResult(); + Assert.IsNotNull(org1.ID); + OrganizationEntity orgDuplicate = new OrganizationEntity(); orgDuplicate.Name = org1.Name; @@ -33,8 +41,6 @@ namespace Tango.UnitTests.DAL repo.Insert(orgDuplicate).GetAwaiter().GetResult(); }); - Assert.IsNotNull(org1.ID); - var org2 = repo.GetAsync(x => x.ID == org1.ID).GetAwaiter().GetResult().FirstOrDefault(); Assert.IsNotNull(org2); diff --git a/Software/Visual_Studio_v2/Tango.UnitTests/Tango.UnitTests.csproj b/Software/Visual_Studio_v2/Tango.UnitTests/Tango.UnitTests.csproj index e79ce12ae..23726f122 100644 --- a/Software/Visual_Studio_v2/Tango.UnitTests/Tango.UnitTests.csproj +++ b/Software/Visual_Studio_v2/Tango.UnitTests/Tango.UnitTests.csproj @@ -72,7 +72,8 @@ </Reference> </ItemGroup> <ItemGroup> - <Compile Include="DAL\Mongo.cs" /> + <Compile Include="BLL\Services\OrganizationsService_TST.cs" /> + <Compile Include="DAL\MongoRepository_TST.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> </ItemGroup> <ItemGroup> @@ -80,6 +81,10 @@ <None Include="packages.config" /> </ItemGroup> <ItemGroup> + <ProjectReference Include="..\Tango.BLL\Tango.BLL.csproj"> + <Project>{5f1f3818-a7e7-4810-95de-f5c1442b21c1}</Project> + <Name>Tango.BLL</Name> + </ProjectReference> <ProjectReference Include="..\Tango.DAL.Mongo\Tango.DAL.Mongo.csproj"> <Project>{9d1f1789-745c-4725-9dc4-12e0b0090a64}</Project> <Name>Tango.DAL.Mongo</Name> |
