LCOV - code coverage report
Current view: top level - Cqrs.Tests/DataStores - CRUD_operations.cs Hit Total Coverage
Test: doc-coverage.info Lines: 0 7 0.0 %
Date: 2017-07-26

          Line data    Source code
       1             : using System;
       2             : using System.Collections.Generic;
       3             : using System.Linq;
       4             : using cdmdotnet.Logging;
       5             : using cdmdotnet.Logging.Configuration;
       6             : using cdmdotnet.StateManagement.Threaded;
       7             : using Cqrs.Configuration;
       8             : using Cqrs.DataStores;
       9             : using Cqrs.Tests.Substitutes;
      10             : using NUnit.Framework;
      11             : 
      12             : namespace Cqrs.Tests.DataStores
      13             : {
      14             :         [TestFixture]
      15             :         public class CRUD_operations
      16           0 :         {
      17             :                 [SetUp]
      18           0 :                 public void Setup()
      19             :                 {
      20             :                 }
      21             : 
      22             :                 [Test]
      23           0 :                 public void GetAllItems()
      24             :                 {
      25             :                         // Arrange
      26             :                         var sqlDataStore = new SqlDataStore<OrderEntity>(new ConfigurationManager(), new ConsoleLogger(new LoggerSettings(), new CorrelationIdHelper(new ThreadedContextItemCollectionFactory())));
      27             : 
      28             :                         // Act
      29             :                         var actualData = sqlDataStore.ToList();
      30             : 
      31             :                         // Assert
      32             :                         Assert.AreEqual(830, actualData.Count);
      33             :                 }
      34             : 
      35             :                 [Test]
      36           0 :                 public void AddSingleItem()
      37             :                 {
      38             :                         // Arrange
      39             :                         var sqlDataStore = new SqlDataStore<OrderEntity>(new ConfigurationManager(), new ConsoleLogger(new LoggerSettings(), new CorrelationIdHelper(new ThreadedContextItemCollectionFactory())));
      40             :                         var entityData = new OrderEntity
      41             :                         {
      42             :                                 Rsn = Guid.NewGuid(),
      43             :                                 CustomerId = "BOLID",
      44             :                                 EmployeeId = 1,
      45             :                                 Freight = 153.24M,
      46             :                                 OrderDate = DateTime.UtcNow.AddDays(-3),
      47             :                                 RequiredDate = DateTime.UtcNow.AddDays(2),
      48             :                                 ShipAddress = "Shipping Address",
      49             :                                 ShipCity = "Shipping City",
      50             :                                 ShipCountry = "ShippingCountry",
      51             :                                 ShipName = "Persons Name",
      52             :                                 ShipPostalCode = "14287",
      53             :                                 ShipRegion = "Region RT",
      54             :                                 ShipViaId = 3,
      55             :                                 ShippedDate = DateTime.UtcNow.AddDays(5),
      56             :                                 SortingOrder = 1
      57             :                         };
      58             : 
      59             :                         // Act
      60             :                         sqlDataStore.Add(entityData);
      61             : 
      62             :                         // Assert
      63             :                         Assert.AreEqual(831, sqlDataStore.ToList().Count);
      64             : 
      65             :                         // Clean-up
      66             :                         sqlDataStore.Destroy(entityData);
      67             :                         Assert.AreEqual(830, sqlDataStore.ToList().Count);
      68             :                 }
      69             : 
      70             :                 [Test]
      71           0 :                 public void AddTwoItems()
      72             :                 {
      73             :                         // Arrange
      74             :                         var sqlDataStore = new SqlDataStore<OrderEntity>(new ConfigurationManager(), new ConsoleLogger(new LoggerSettings(), new CorrelationIdHelper(new ThreadedContextItemCollectionFactory())));
      75             :                         var entityData = new List<OrderEntity>
      76             :                         {
      77             :                                 new OrderEntity
      78             :                                 {
      79             :                                         Rsn = Guid.NewGuid(),
      80             :                                         CustomerId = "BOLID",
      81             :                                         EmployeeId = 1,
      82             :                                         Freight = 153.24M,
      83             :                                         OrderDate = DateTime.UtcNow.AddDays(-3),
      84             :                                         RequiredDate = DateTime.UtcNow.AddDays(2),
      85             :                                         ShipAddress = "Shipping Address",
      86             :                                         ShipCity = "Shipping City",
      87             :                                         ShipCountry = "ShippingCountry",
      88             :                                         ShipName = "Persons Name",
      89             :                                         ShipPostalCode = "14287",
      90             :                                         ShipRegion = "Region RT",
      91             :                                         ShipViaId = 3,
      92             :                                         ShippedDate = DateTime.UtcNow.AddDays(5),
      93             :                                         SortingOrder = 1
      94             :                                 },
      95             :                                                                 new OrderEntity
      96             :                                 {
      97             :                                         Rsn = Guid.NewGuid(),
      98             :                                         CustomerId = "BOLID",
      99             :                                         EmployeeId = 2,
     100             :                                         Freight = 742.15M,
     101             :                                         OrderDate = DateTime.UtcNow.AddDays(-4),
     102             :                                         RequiredDate = DateTime.UtcNow.AddDays(1),
     103             :                                         ShipAddress = "Shipping Address",
     104             :                                         ShipCity = "Shipping City",
     105             :                                         ShipCountry = "ShippingCountry",
     106             :                                         ShipName = "Persons Name",
     107             :                                         ShipPostalCode = "14287",
     108             :                                         ShipRegion = "Region RT",
     109             :                                         ShipViaId = 2,
     110             :                                         ShippedDate = DateTime.UtcNow.AddDays(9),
     111             :                                         SortingOrder = 2
     112             :                                 }
     113             :                         };
     114             : 
     115             :                         // Act
     116             :                         sqlDataStore.Add(entityData);
     117             : 
     118             :                         // Assert
     119             :                         Assert.AreEqual(832, sqlDataStore.ToList().Count);
     120             : 
     121             :                         // Clean-up
     122             :                         foreach (OrderEntity orderEntity in entityData)
     123             :                                 sqlDataStore.Destroy(orderEntity);
     124             :                         Assert.AreEqual(830, sqlDataStore.ToList().Count);
     125             :                 }
     126             : 
     127             :                 [Test]
     128           0 :                 public void UpdateSingleItem()
     129             :                 {
     130             :                         // Arrange
     131             :                         var sqlDataStore = new SqlDataStore<OrderEntity>(new ConfigurationManager(), new ConsoleLogger(new LoggerSettings(), new CorrelationIdHelper(new ThreadedContextItemCollectionFactory())));
     132             :                         var entityData = new OrderEntity
     133             :                         {
     134             :                                 Rsn = Guid.NewGuid(),
     135             :                                 CustomerId = "BOLID",
     136             :                                 EmployeeId = 1,
     137             :                                 Freight = 153.24M,
     138             :                                 OrderDate = DateTime.UtcNow.AddDays(-3),
     139             :                                 RequiredDate = DateTime.UtcNow.AddDays(2),
     140             :                                 ShipAddress = "Shipping Address",
     141             :                                 ShipCity = "Shipping City",
     142             :                                 ShipCountry = "ShippingCountry",
     143             :                                 ShipName = "Persons Name",
     144             :                                 ShipPostalCode = "14287",
     145             :                                 ShipRegion = "Region RT",
     146             :                                 ShipViaId = 3,
     147             :                                 ShippedDate = DateTime.UtcNow.AddDays(5),
     148             :                                 SortingOrder = 1
     149             :                         };
     150             :                         sqlDataStore.Add(entityData);
     151             :                         entityData = sqlDataStore.Single(e => e.Rsn.Equals(entityData.Rsn));
     152             :                         entityData.CustomerId = "CHOPS";
     153             : 
     154             :                         // Act
     155             :                         sqlDataStore.Update(entityData);
     156             : 
     157             :                         // Assert
     158             :                         entityData = sqlDataStore.Single(e => e.Rsn.Equals(entityData.Rsn)); ;
     159             :                         Assert.AreEqual("CHOPS", entityData.CustomerId);
     160             : 
     161             :                         // Clean-up
     162             :                         sqlDataStore.Destroy(entityData);
     163             :                         Assert.AreEqual(830, sqlDataStore.ToList().Count);
     164             :                 }
     165             : 
     166             :                 [Test]
     167           0 :                 public void RemoveSingleItem()
     168             :                 {
     169             :                         // Arrange
     170             :                         var sqlDataStore = new SqlDataStore<OrderEntity>(new ConfigurationManager(), new ConsoleLogger(new LoggerSettings(), new CorrelationIdHelper(new ThreadedContextItemCollectionFactory())));
     171             :                         var entityData = new OrderEntity
     172             :                         {
     173             :                                 Rsn = Guid.NewGuid(),
     174             :                                 CustomerId = "BOLID",
     175             :                                 EmployeeId = 1,
     176             :                                 Freight = 153.24M,
     177             :                                 OrderDate = DateTime.UtcNow.AddDays(-3),
     178             :                                 RequiredDate = DateTime.UtcNow.AddDays(2),
     179             :                                 ShipAddress = "Shipping Address",
     180             :                                 ShipCity = "Shipping City",
     181             :                                 ShipCountry = "ShippingCountry",
     182             :                                 ShipName = "Persons Name",
     183             :                                 ShipPostalCode = "14287",
     184             :                                 ShipRegion = "Region RT",
     185             :                                 ShipViaId = 3,
     186             :                                 ShippedDate = DateTime.UtcNow.AddDays(5),
     187             :                                 SortingOrder = 1
     188             :                         };
     189             :                         sqlDataStore.Add(entityData);
     190             :                         entityData = sqlDataStore.Single(e => e.Rsn.Equals(entityData.Rsn));
     191             : 
     192             :                         // Act
     193             :                         sqlDataStore.Remove(entityData);
     194             : 
     195             :                         // Assert
     196             :                         entityData = sqlDataStore.Single(e => e.Rsn.Equals(entityData.Rsn)); ;
     197             :                         Assert.IsTrue(entityData.IsLogicallyDeleted);
     198             : 
     199             :                         // Clean-up
     200             :                         sqlDataStore.Destroy(entityData);
     201             :                         Assert.AreEqual(830, sqlDataStore.ToList().Count);
     202             :                 }
     203             :         }
     204             : }

Generated by: LCOV version 1.10