public void DeleteThreadFromDatabase()
        {
            var order = UnderTest.Model;

            UpdateOrder(order);

            var expectedThread = new
            {
                Length            = 2,
                ThreadReferenceId = 1
            };

            var thread = new OrderThread
            {
                Length            = expectedThread.Length,
                ThreadReferenceId = expectedThread.ThreadReferenceId
            };

            order.Threads = thread.AsList();
            UnderTest.SaveCommand.Execute(null);

            HasEntries <Order>(1);
            HasEntries <ThreadBase>(1);

            UnderTest.DeleteThreadCommand.Execute(thread);
            UnderTest.SaveCommand.Execute(null);

            HasEntries <Order>(1);
            HasEntries <ThreadBase>(0);
        }
        public void SavingNewOrderWithThread()
        {
            var order = UnderTest.Model;

            UpdateOrder(order);

            var expectedThread = new
            {
                Length            = 2,
                ThreadReferenceId = 1
            };

            var thread = new OrderThread
            {
                Length            = expectedThread.Length,
                ThreadReferenceId = expectedThread.ThreadReferenceId
            };

            order.Threads = thread.AsList();
            UnderTest.SaveCommand.Execute(null);

            var dbOrder = _orderRepository.GetAll().Last();

            dbOrder.Should().BeEquivalentTo(order, opt => opt.Excluding(o => o.Threads));
            dbOrder.Threads.Should().HaveCount(1);
            dbOrder.Threads.Should().BeEquivalentTo(expectedThread);

            HasEntries <Order>(1);
            HasEntries <ThreadBase>(1);
        }
Ejemplo n.º 3
0
        public void Create_thread_fail()
        {
            //Arrange
            AddThreadCommand command = null;

            //Act - Assert
            Assert.Throws <ArgumentNullException>(() => OrderThread.CreateNew(command));
        }
Ejemplo n.º 4
0
        public void Finish_order_fail()
        {
            //Arrange
            var order = Order.CreateNew(new AddOrderCommand {
                State = OrderState.Waiting
            });
            AddThreadCommand command = null;

            //Act - Assert
            Assert.Throws <ArgumentNullException>(() => order.Finish(OrderThread.CreateNew(command)));
        }
Ejemplo n.º 5
0
        public void Update_thread_interval_should_has_positive_value()
        {
            //Arrange
            var thread = OrderThread.CreateNew(new AddThreadCommand {
                State = OrderThreadState.Stopped
            });
            int interval = -100;

            //Act - Assert
            Assert.Throws <ArgumentException>(() => thread.UpdateInterval(interval));
        }
Ejemplo n.º 6
0
        public void Create_thread_success()
        {
            //Arrange
            var command = new AddThreadCommand {
                State = OrderThreadState.Stopped
            };

            //Act
            var thread = OrderThread.CreateNew(command);

            //Assert
            Assert.NotNull(thread);
        }
Ejemplo n.º 7
0
        public void Update_thread_interval_success()
        {
            //Arrange
            var thread = OrderThread.CreateNew(new AddThreadCommand {
                State = OrderThreadState.Stopped
            });
            int interval = 100;

            //Act
            thread.UpdateInterval(interval);

            //Assert
            Assert.NotNull(thread);
        }
        public void DeleteThreadFromOrder()
        {
            var orderThread = new OrderThread
            {
                ThreadReference = ThreadReferences.Data[0]
            };

            var order = UnderTest.Model;

            order.Threads = orderThread.AsList();

            UnderTest.DeleteThreadCommand.Execute(orderThread);

            order.Threads.Should().BeEmpty();
        }
Ejemplo n.º 9
0
        public void Finish_order_success()
        {
            //Arrange
            var order = Order.CreateNew(new AddOrderCommand {
                State = OrderState.Waiting
            });

            //Act
            order.Finish(OrderThread.CreateNew(new AddThreadCommand {
                State = OrderThreadState.Stopped
            }));

            //Assert
            Assert.NotNull(order);
        }
 private OrderThread FakeThread()
 {
     return(OrderThread.CreateNew(FakeCommand()));
 }
Ejemplo n.º 11
0
 public OrderThread AddNew(OrderThread thread)
 {
     return(_context.Threads.Add(thread).Entity);
 }
Ejemplo n.º 12
0
 public ThreadDTO(OrderThread thread)
 {
     Id       = thread.Id;
     Interval = thread.Interval;
     State    = thread.State;
 }