Пример #1
0
        public void Edit_Success()
        {
            // Arrange
            var diver = DiverFactory.CreateJohnDoe();

            // Act
            diver.Edit(
                DiverFactory.JaneDoeDiverId,
                "John Doe New",
                "John New",
                "Doe New",
                "New Skill Level",
                "3000 Dives",
                "New Slogan",
                "+41 999 88 77",
                "https://john.com",
                "joFb",
                "doe",
                "doe.john");

            // Assert
            diver.UncommittedDomainEvents.Should().ContainSingle(e =>
                                                                 e.GetType() == typeof(UserProfileEditedEvent) &&
                                                                 ((UserProfileEditedEvent)e).EditedDiverId == DiverFactory.JohnDoeDiverId &&
                                                                 ((UserProfileEditedEvent)e).EditedByDiverId == DiverFactory.JaneDoeDiverId);
        }
Пример #2
0
        private static Diver CreateTestUser(DateTime lastNotificationCheckAt, int notificationIntervalInHours)
        {
            var result = DiverFactory.CreateJohnDoe();

            result.LastNotificationCheckAt     = lastNotificationCheckAt;
            result.NotificationIntervalInHours = notificationIntervalInHours;

            return(result);
        }
        public GetEditAvatarInteractorTests()
        {
            editJohnDoeAvatarRequest = new GetEditAvatar(DiverFactory.JohnDoeDiverId, outputPort);

            A.CallTo(() => diverRepository.FindByIdAsync(A <Guid> ._))
            .ReturnsLazily(call => Task.FromResult(
                               (Guid)call.Arguments[0] == DiverFactory.JohnDoeDiverId
                        ? DiverFactory.CreateJohnDoe()
                        : null));

            interactor = new GetEditAvatarInteractor(logger, diverRepository, currentUser);
        }
Пример #4
0
        public GetUserProfileInteractorTests()
        {
            A.CallTo(() => diverRepository.FindByIdAsync(A <Guid> ._))
            .ReturnsLazily((call) => Task.FromResult(
                               (Guid)call.Arguments[0] == DiverFactory.JohnDoeDiverId
                        ? DiverFactory.CreateJohnDoe()
                        : null));

            var logger = A.Fake <ILogger <GetUserProfileInteractor> >();

            interactor = new GetUserProfileInteractor(diverRepository, currentUser, userManager, logger);
        }
        public async Task Handle_CurrentDiver_Success()
        {
            // Arrange
            A.CallTo(() => currentUser.GetCurrentDiverAsync())
            .ReturnsLazily(() => Task.FromResult(DiverFactory.CreateJohnDoe()));

            // Act
            var result = await interactor.Handle(editJohnDoeAvatarRequest, CancellationToken.None);

            // Assert
            result.IsSuccessful.Should().BeTrue();
            A.CallTo(() => outputPort.Output(A <GetEditAvatarOutput> ._))
            .MustHaveHappenedOnceExactly();
        }
        public async Task Handle_UnknownDiver_FailWithNotFound()
        {
            // Arrange
            A.CallTo(() => currentUser.GetCurrentDiverAsync())
            .ReturnsLazily(() => Task.FromResult(DiverFactory.CreateJohnDoe()));
            var request = new GetEditAvatar(DiverFactory.JaneDoeDiverId, outputPort);

            // Act
            var result = await interactor.Handle(request, CancellationToken.None);

            // Assert
            result.IsSuccessful.Should().BeFalse();
            result.ResultCategory.Should().Be(ResultCategory.NotFound);
            A.CallTo(() => outputPort.Output(A <GetEditAvatarOutput> ._))
            .MustNotHaveHappened();
        }
Пример #7
0
        public async Task Handle_OwnUser_MustBeAllowedToEdit()
        {
            // Arrange
            var request = new GetUserProfile(DiverFactory.JohnDoeDiverId, outputPort);

            A.CallTo(() => currentUser.GetCurrentDiverAsync())
            .ReturnsLazily(() => Task.FromResult(DiverFactory.CreateJohnDoe()));

            // Act
            var interactorResult = await interactor.Handle(request, CancellationToken.None);

            // Assert
            interactorResult.IsSuccessful.Should().BeTrue();
            A.CallTo(() => outputPort.Output(A <GetUserProfileOutput> .That.Matches(o => o.AllowEdit == true)))
            .MustHaveHappenedOnceExactly();
        }