public async Task GetActualDonationsForTeam() { var adminController = AdminControllerTest.GetAdminController(); var actualDonationsList = await adminController.GetTeamDonations(testEvent.ID, team1.ID); var expectedDonationsList = team1Donations; actualDonationsList.Should().BeEquivalentTo(expectedDonationsList, options => options.Excluding(d => d.ID)); }
public async Task GetActualDonationsForEvent() { var adminController = AdminControllerTest.GetAdminController(); var actualDonationsList = await adminController.GetEventDonations(testEvent.ID); var expectedDonationsList = new List <DtoDonation>(); expectedDonationsList.Add(dtoDonation); expectedDonationsList.AddRange(team1Donations); expectedDonationsList.AddRange(team2Donations); actualDonationsList.Should().BeEquivalentTo(expectedDonationsList, options => options.Excluding(d => d.ID)); }
public async Task ValidAuthentication_PopulateAdminFromDb_ContinuePipeline() { var auth = AuthenticationTest.GetTestAuth(); auth.Code = authCode; auth.UserType = UserType.Admin; auth.Expires = DateTime.Now.Add(TimeSpan.FromDays(1)); const int customStatusCode = 123; var mockRepo = new Mock <IAuthenticationRepository>(); mockRepo.Setup(r => r.GetByCode(authCode)) .ReturnsAsync(auth); AdminControllerTest.Init(); auth.Username = AdminControllerTest.tmpAdmin.Username; var mockAdminRepo = new Mock <IAdminRepository>(); mockAdminRepo.Setup(r => r.GetByUsername(auth.Username)) .ReturnsAsync(AdminControllerTest.tmpAdmin); var context = new DefaultHttpContext(); var middleware = new AuthenticationMiddleware(httpContext => { httpContext.Response.StatusCode = customStatusCode; return(Task.CompletedTask); }); context.Response.Body = new MemoryStream(); context.Request.Headers["authCode"] = authCode; await middleware.Invoke(context, mockRepo.Object, mockAdminRepo.Object); Assert.Equal(customStatusCode, context.Response.StatusCode); Assert.Equal(AdminControllerTest.tmpAdmin, context.Items["admin"] as Admin); }