Beispiel #1
0
        public void CreateAsync_Shold_Be_Success()
        {
            _environmentRepositoryMock.Setup(x => x.AddAsync(It.IsAny <Domain.Entities.Environment>(), It.IsAny <string>()))
            .Returns(Task.FromResult <object>(null));

            var environmentAppService = new EnvironmentAppService(_mapper.Object, _environmentValidator, GetCosmosToggleDataContext(_environmentRepositoryMock.Object),
                                                                  _notificationContext.Object, _authAppServiceMock.Object);

            Func <Task> action = async() => { await environmentAppService.CreateAsync(GetDtoEnvironment()); };

            action.Should().NotThrowAsync();
        }
Beispiel #2
0
        public void CreateAsync_EnvironmentName_Null_Shold_Be_ValidationException()
        {
            var environmentAppService = new EnvironmentAppService(_mapper.Object, _environmentValidator,
                                                                  GetCosmosToggleDataContext(_environmentRepositoryMock.Object), _notificationContext.Object, _authAppServiceMock.Object);

            var environment = GetDtoEnvironment();

            environment.Name = null;

            Func <Task> action = async() => { await environmentAppService.CreateAsync(environment); };

            action.Should().ThrowExactly <ValidationException>();
        }
Beispiel #3
0
        public void GetByProjectAsync_Shold_Be_Success()
        {
            _environmentRepositoryMock.Setup(x => x.GetByProjectAsync(It.IsAny <string>()))
            .Returns(Task.FromResult <IEnumerable <Domain.Entities.Environment> >(new List <Domain.Entities.Environment>()
            {
                GetEntityEnvironment()
            }));

            var environmentAppService = new EnvironmentAppService(_mapper.Object, _environmentValidator,
                                                                  GetCosmosToggleDataContext(_environmentRepositoryMock.Object), _notificationContext.Object, _authAppServiceMock.Object);

            Func <Task> action = async() => { await environmentAppService.GetByProjectAsync("123456"); };

            action.Should().NotThrowAsync();
        }
Beispiel #4
0
        public void GetByProjectAsync_Shold_Be_NullAndHasNotFoundNotification()
        {
            _environmentRepositoryMock.Setup(x => x.GetByProjectAsync(It.IsAny <string>()))
            .Returns(Task.FromResult <IEnumerable <Domain.Entities.Environment> >(null));

            var notificationContext = new NotificationContext {
            };

            var environmentAppService = new EnvironmentAppService(_mapper.Object, _environmentValidator,
                                                                  GetCosmosToggleDataContext(_environmentRepositoryMock.Object), notificationContext, _authAppServiceMock.Object);

            Func <Task> action = async() => { await environmentAppService.GetByProjectAsync("123456"); };

            action.Should().NotThrowAsync();

            notificationContext.HasNotifications.Should().Be(true);
            notificationContext.Notifications.Where(x => x.Code == HttpStatusCode.NotFound);
        }