public void Ctor__FinishDateTimeIsNotNull()
        {
            // Arrange
            // Act
            var request = new FinishOrderCommandRequestV2();

            // Assert
            Assert.NotNull(request.FinishDateTime);
        }
        public void Ctor__FinishDateTimeIsNotDefault()
        {
            // Arrange
            var request = new FinishOrderCommandRequestV2();
            // Act
            var finishDateTime = request.FinishDateTime;

            // Assert
            Assert.NotEqual(default(DateTime), finishDateTime);
        }
Exemple #3
0
        public FinishOrderCommandHandlerV2Tests()
        {
            var orderId = _faker.Random.Int(min: 0);

            _finishDateTime = _faker.Date.Recent();
            _order          = new Order()
            {
                Id = orderId, FinishDateTime = null, Status = ""
            };
            var orders = new List <Order>()
            {
                _order
            };
            var ordersAsQueryable = orders.AsQueryable();
            var dbContext         = Substitute.For <OrderContext>();
            var appSettings       = AppSettingsFake.Generate();

            #region DbContext

            var ordersDbSet = Substitute.For <DbSet <Order>, IQueryable <Order> >();
            ((IQueryable <Order>)ordersDbSet).Provider.Returns(ordersAsQueryable.Provider);
            ((IQueryable <Order>)ordersDbSet).Expression.Returns(ordersAsQueryable.Expression);
            ((IQueryable <Order>)ordersDbSet).ElementType.Returns(ordersAsQueryable.ElementType);
            ((IQueryable <Order>)ordersDbSet).GetEnumerator().Returns(ordersAsQueryable.GetEnumerator());

            dbContext.Orders.Returns(ordersDbSet);
            dbContext.SaveChanges().Returns(1);

            #endregion

            #region DbContextFactory

            var dbContextFactory = Substitute.For <IDbContextFactory <OrderContext> >();
            dbContextFactory.Create(appSettings.ConnectionStrings.OrdersDb).Returns(dbContext);

            #endregion

            _handler        = CreateTestedComponent(appSettings, dbContextFactory);
            _commandRequest = new FinishOrderCommandRequestV2()
            {
                OrderId        = orderId,
                FinishDateTime = _finishDateTime
            };
        }