diff options
Diffstat (limited to 'Software/Visual_Studio_v2/Tango.UnitTests/DAL')
| -rw-r--r-- | Software/Visual_Studio_v2/Tango.UnitTests/DAL/Mongo.cs | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/Software/Visual_Studio_v2/Tango.UnitTests/DAL/Mongo.cs b/Software/Visual_Studio_v2/Tango.UnitTests/DAL/Mongo.cs new file mode 100644 index 000000000..8a2314858 --- /dev/null +++ b/Software/Visual_Studio_v2/Tango.UnitTests/DAL/Mongo.cs @@ -0,0 +1,45 @@ +using System; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Tango.DAL.Entities; +using Tango.DAL.Mongo; +using System.Linq; + +namespace Tango.UnitTests.DAL +{ + [TestClass] + public class Mongo + { + [TestMethod] + public void Simple_Operations() + { + MongoRepository<OrganizationEntity> repo = new MongoRepository<OrganizationEntity>(new MongoDataBaseSettings() + { + Address = "mongodb://localhost:27017", + DatabaseName = "TEST" + }); + + repo.DeleteAsync(x => true).GetAwaiter().GetResult(); + + OrganizationEntity org1 = new OrganizationEntity(); + org1.Name = "Org 1"; + + repo.Insert(org1).GetAwaiter().GetResult(); + + Assert.IsNotNull(org1.ID); + + var org2 = repo.GetAsync(x => x.ID == org1.ID).GetAwaiter().GetResult().FirstOrDefault(); + + Assert.IsNotNull(org2); + + Assert.AreEqual(org1.Name, org2.Name); + + long count = repo.DeleteAsync(x => x.ID == org1.ID).GetAwaiter().GetResult(); + + Assert.AreEqual(count, 1); + + count = repo.Count().GetAwaiter().GetResult(); + + Assert.AreEqual(count, 0); + } + } +} |
