public void CheckInsertMethodCalled()
        {
            // Arrange
            Mock <IClientRepository> repositoryMock = new Mock <IClientRepository>();
            IClientService           service        = new ClientService(repositoryMock.Object);
            var client = ClientObjectMother.CreateClient();

            // Act
            service.Insert(client);

            // Assert
            repositoryMock.Verify(k => k.Insert(client), Times.Once());
        }
Beispiel #2
0
        public void CheckCreatingClient()
        {
            // Arrange
            Client client = ClientObjectMother.CreateClient();

            deliveryFactoryMock.Setup(factory =>
                                      factory.CreateClient(client.name, client.surname, client.phone_number, client.email, client.address))
            .Returns(client);

            // Act
            Client returnedClient = deliveryService.CreateNewClient(client.name, client.surname, client.phone_number, client.email, client.address);

            // Assert
            clientRepositoryMock.Verify(r => r.InsertClient(client), Times.Once());
            Assert.AreSame(client, returnedClient);
        }
Beispiel #3
0
        public void CheckCreatingOrder()
        {
            // Arrange
            Client        client = ClientObjectMother.CreateClient();
            DeliveryOrder order  = OrderObjectMother.CreateOrder();

            deliveryFactoryMock.Setup(factory =>
                                      factory.CreateOrder(order.size, order.weight))
            .Returns(order);

            // Act
            DeliveryOrder createdOrder = deliveryService.CreateNewOrder(order.size, order.weight, client);

            // Assert
            orderRepositoryMock.Verify(r => r.InsertOrder(order), Times.Once());
            Assert.AreSame(order, createdOrder);
            Assert.AreSame(order.client, client);
            Assert.IsTrue(client.orders.Contains(order));
        }