コード例 #1
0
        public void StockBuilder_ShouldHaveSame_Date_AsEntity_WhenCreated()
        {
            DateTime expected = DateTime.Now;

            mockStockEntity.Setup(pe => pe.Date).Returns(expected);

            StockConverter builder = CreateStockBuilderWithMocks();
            DateTime       actual  = builder.Convert(mockStockEntity.Object, (a, b) => { }).Date;

            Assert.AreEqual(expected, actual);
        }
コード例 #2
0
        public void StockBuilder_ShouldHaveSame_Amount_AsEntity_WhenCreated()
        {
            int expected = 333;

            mockStockEntity.Setup(entity => entity.Amount).Returns(expected);

            StockConverter builder = CreateStockBuilderWithMocks();
            int            actual  = builder.Convert(mockStockEntity.Object, (a, b) => { }).Amount;

            Assert.AreEqual(expected, actual);
        }
コード例 #3
0
 public ConverterFactory(IDomainFactory domainFactory,
                         IEntityFactory entityFactory,
                         IRepositoryFactory repositoryFactory,
                         IDAOFactory daoFactory)
 {
     this.domainFactory     = domainFactory;
     this.entityFactory     = entityFactory;
     this.repositoryFactory = repositoryFactory;
     this.daoFactory        = daoFactory;
     productConverter       = new ProductConverter(this.domainFactory, this.repositoryFactory);
     productEntityConverter = new ProductEntityConverter(entityFactory, daoFactory);
     stockConverter         = new StockConverter(domainFactory, repositoryFactory);
     stockEntityConverter   = new StockEntityConverter(entityFactory, daoFactory);
     tagConverter           = new TagConverter(domainFactory, repositoryFactory);
     tagEntityConverter     = new TagEntityConverter(entityFactory, daoFactory);
 }
コード例 #4
0
        public void GetResult_ShouldReturnStock_WithSameBasicProperties_AsStockEntity()
        {
            /* ARRANGE */
            StockEntity basicProps = new StockEntity {
                Id = 111, ProductId = 222, Amount = 300, Date = DateTime.Now
            };

            SetBasicPropertiesInMockStockEntity(basicProps);
            SetupMockDomainFactoryToReturnStock();

            /* ACT */
            StockConverter builder = CreateStockBuilderWithMocks();
            IStock         stock   = builder.Convert(basicProps, (a, b) => { });

            /* ASSERT */
            Assert.AreEqual(stock.Id, basicProps.Id);
            Assert.AreEqual(stock.ProductId, basicProps.ProductId);
            Assert.AreEqual(stock.Amount, basicProps.Amount);
            Assert.AreEqual(stock.Date, basicProps.Date);
        }
コード例 #5
0
        public void BuildProduct_ShouldSet_ProductId_ToMatchProductIdIn_Stock()
        {
            /* ARRANGE */
            int         expectedProductId = 111;
            StockEntity basicProps        = new StockEntity {
                Id = 111, ProductId = expectedProductId, Amount = 300, Date = DateTime.Now
            };

            SetBasicPropertiesInMockStockEntity(basicProps);
            SetupMockRepositoryFactoryToReturnProduct();

            /* ACT */
            StockConverter builder = CreateStockBuilderWithMocks();
            //builder.BuildProduct();

            /* ASSERT */
            int actual = builder.Convert(basicProps, (a, b) => { }).Product.Id;

            Assert.AreEqual(expectedProductId, actual);
        }
コード例 #6
0
        public void GetResult_ShouldReturnStock_WithSameProduct_AsStockEntity_WhenUsedAfter_BuildProduct()
        {
            /* ARRANGE */
            int         expectedProductId = 222;
            StockEntity basicProps        = new StockEntity {
                Id = 111, ProductId = expectedProductId, Amount = 300, Date = DateTime.Now
            };

            SetBasicPropertiesInMockStockEntity(basicProps);
            SetupMockDomainFactoryToReturnStock();
            SetupMockRepositoryFactoryToReturnProduct();

            /* ACT */
            StockConverter builder = CreateStockBuilderWithMocks();
            //builder.BuildProduct();
            IStock stock = builder.Convert(basicProps, (a, b) => { });

            /* ASSERT */
            int actual = stock.Product.Id;

            Assert.AreEqual(expectedProductId, actual);
        }