Esempio n. 1
0
        public async Task GetOwner_ReturnsOwner()
        {
            // Arrange
            var deliveryRepository = new Mock <IDeliveryRepository>();

            deliveryRepository.Setup(r => r.GetAsync(It.IsAny <string>()))
            .ReturnsAsync(delivery);

            var loggerFactory = new Mock <ILoggerFactory>();

            loggerFactory.Setup(f => f.CreateLogger(It.IsAny <string>())).Returns(new Mock <ILogger>().Object);

            var target = new DeliveriesController(deliveryRepository.Object,
                                                  new Mock <INotifyMeRequestRepository>().Object,
                                                  new Mock <INotificationService>().Object,
                                                  new Mock <IDeliveryTrackingEventRepository>().Object,
                                                  loggerFactory.Object);

            // Act
            var result = await target.GetOwner("deliveryid") as OkObjectResult;

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(userAccount, result.Value);
        }
Esempio n. 2
0
        public async Task GetOwner_Returns404_IfDeliveryIdNotValid()
        {
            // Arrange
            var loggerFactory = new Mock <ILoggerFactory>();

            loggerFactory.Setup(f => f.CreateLogger(It.IsAny <string>())).Returns(new Mock <ILogger>().Object);

            var target = new DeliveriesController(new Mock <IDeliveryRepository>().Object,
                                                  new Mock <INotifyMeRequestRepository>().Object,
                                                  new Mock <INotificationService>().Object,
                                                  new Mock <IDeliveryTrackingEventRepository>().Object,
                                                  loggerFactory.Object);

            // Act
            var result = await target.GetOwner("invaliddeliveryid") as NotFoundResult;

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(404, result.StatusCode);
        }