public async Task AddMembersToClubAsync_CommandResult_UsersToAddNotFoundByUsername() { //arrange string existingClubName = "C# Knights"; var clubsToPreload = new Club[] { new Club { Name = existingClubName } }; var members = new User[] { new User { Username = "******" } }; IEntityGateway entityGateway = await InMemoryEntityGatewayFactory.CreateEntityGatewayAsync(clubsToPreload); IAddMembersToClubPresenter presenter = new FakeAddMembersToClubPresenter(_output); IAddMembersToClubInteractor interactor = new AddMembersToClubInteractor(presenter, entityGateway); AddMembersToClubInputModel inputModel = new AddMembersToClubInputModel { ClubModel = new Domain.Model.ClubModel { Name = existingClubName }, UserModelsToAdd = members.Select(member => member.GetModel()).ToList() }; //act var result = await interactor.AddMembersToClubAsync(inputModel); //assert Assert.NotNull(result); Assert.True(result.Status == Application.Common.CommandResultStatusCode.UsersInListNotFound); }
public async Task AddMembersToClubAsync_CommandResult_ClubNotFoundById() { //arrange var nonExistingClubId = Guid.NewGuid(); string existingMemberUsername = "******"; var members = new User[] { new User { Username = existingMemberUsername } }; IEntityGateway entityGateway = await InMemoryEntityGatewayFactory.CreateEntityGatewayAsync(members); IAddMembersToClubPresenter presenter = new FakeAddMembersToClubPresenter(_output); IAddMembersToClubInteractor interactor = new AddMembersToClubInteractor(presenter, entityGateway); AddMembersToClubInputModel inputModel = new AddMembersToClubInputModel { ClubModel = new Domain.Model.ClubModel { Id = nonExistingClubId }, UserModelsToAdd = members.Select(member => member.GetModel()).ToList() }; //act var result = await interactor.AddMembersToClubAsync(inputModel); //assert Assert.NotNull(result); Assert.True(result.Status == Application.Common.CommandResultStatusCode.ClubNotFound); }
public async Task AddMembersToClubAsync_CommandResult_MissingClubFromInput1() { //arrange IEntityGateway entityGateway = InMemoryEntityGatewayFactory.CreateEntityGateway(); IAddMembersToClubPresenter presenter = new FakeAddMembersToClubPresenter(_output); IAddMembersToClubInteractor interactor = new AddMembersToClubInteractor(presenter, entityGateway); AddMembersToClubInputModel inputModel = new AddMembersToClubInputModel(); //act var result = await interactor.AddMembersToClubAsync(inputModel); //assert Assert.NotNull(result); Assert.True(result.Status == Application.Common.CommandResultStatusCode.MissingClub); }
public async Task AddMembersToClubAsync_CommandResult_MissingUsersToAddFromInput2() { //arrange string existingClubName = "C# Knights"; var clubsToPreload = new Club[] { new Club { Name = existingClubName } }; IEntityGateway entityGateway = await InMemoryEntityGatewayFactory.CreateEntityGatewayAsync(clubsToPreload); IAddMembersToClubPresenter presenter = new FakeAddMembersToClubPresenter(_output); IAddMembersToClubInteractor interactor = new AddMembersToClubInteractor(presenter, entityGateway); AddMembersToClubInputModel inputModel = new AddMembersToClubInputModel { ClubModel = new Domain.Model.ClubModel { Name = existingClubName }, UserModelsToAdd = null }; //act var result = await interactor.AddMembersToClubAsync(inputModel); //assert Assert.NotNull(result); Assert.True(result.Status == Application.Common.CommandResultStatusCode.MissingUsersToAdd); }
public async Task AddMembersToClubAsync_ThrowsException_NullInput() { //arrange IEntityGateway entityGateway = InMemoryEntityGatewayFactory.CreateEntityGateway(); IAddMembersToClubPresenter presenter = new FakeAddMembersToClubPresenter(_output); IAddMembersToClubInteractor interactor = new AddMembersToClubInteractor(presenter, entityGateway); AddMembersToClubInputModel inputModel = null; //act async Task <CommandResult <AddMembersToClubOutputModel> > function() => await interactor.AddMembersToClubAsync(inputModel); //assert await Assert.ThrowsAsync <ArgumentNullException>(function); }