public async Task ShouldCreateShooterAssociationInfoBeOkHavingProvidedData() { var shooterIds = Scenario.ShooterAssociationInfos.Select(x => x.ShooterId).ToList(); var existing = Scenario.Shooters.FirstOrDefault(x => !shooterIds.Contains(x.Id)); if (existing == null) { Assert.Inconclusive("No shooter without association exists"); } //Conteggio gli elementi prima della creazione var countBefore = Scenario.ShooterAssociationInfos.Count; var existingAssociation = Scenario.Associations.FirstOrDefault(); //Composizione della request var request = new ShooterAssociationInfoCreateRequest { AssociationId = existingAssociation.Id, ShooterId = existing.Id, SafetyOfficier = true, RegistrationDate = RandomizationUtils.GetRandomDate(), CardNumber = RandomizationUtils.GenerateRandomString(5), Categories = new List <string> { existingAssociation.Categories.FirstOrDefault() } }; //Invoke del metodo var response = await Controller.CreateShooterAssociationInfo(request); //Conteggio gli elementi dopo la creazione var countAfter = Scenario.ShooterAssociationInfos.Count; //Parsing della risposta e assert var parsed = ParseExpectedOk <ShooterAssociationInfoContract>(response); Assert.IsTrue(parsed != null && countAfter == countBefore + 1 && parsed != null && parsed.Data.Association.AssociationId == request.AssociationId && parsed.Data.Shooter.ShooterId == request.ShooterId && parsed.Data.RegistrationDate == request.RegistrationDate && parsed.Data.SafetyOfficier == request.SafetyOfficier && parsed.Data.CardNumber == request.CardNumber && parsed.Data.Categories.All(x => request.Categories.Contains(x)) ); }
public async Task ShouldCreateShooterTeamPaymentBeOkHavingProvidedData() { var shooterIds = Scenario.ShooterTeamPayments.Select(x => x.ShooterId).ToList(); var existing = Scenario.Shooters.FirstOrDefault(x => !shooterIds.Contains(x.Id)); if (existing == null) { Assert.Inconclusive("No shooter team payment without association exists"); } //Conteggio gli elementi prima della creazione var countBefore = Scenario.ShooterTeamPayments.Count; var existingTeam = Scenario.Teams.FirstOrDefault(); //Composizione della request var request = new ShooterTeamPaymentCreateRequest { TeamId = existingTeam.Id, ShooterId = existing.Id, Reason = RandomizationUtils.GenerateRandomString(15), Amount = 1, PaymentDateTime = RandomizationUtils.GetRandomDate() }; //Invoke del metodo var response = await Controller.CreateShooterTeamPayment(request); //Conteggio gli elementi dopo la creazione var countAfter = Scenario.ShooterTeamPayments.Count; //Parsing della risposta e assert var parsed = ParseExpectedOk <ShooterTeamPaymentContract>(response); var updatedEntity = Scenario.ShooterTeamPayments.FirstOrDefault(x => x.Id == parsed.Data.ShooterTeamPaymentId); Assert.IsTrue(parsed != null && countAfter == countBefore + 1 && updatedEntity.TeamId == request.TeamId && updatedEntity.ShooterId == request.ShooterId && updatedEntity.Amount == request.Amount && updatedEntity.Reason == request.Reason && updatedEntity.PaymentDateTime == request.PaymentDateTime && updatedEntity.ExpireDateTime == request.ExpireDateTime && updatedEntity.NotifyExpiration == request.NotifyExpiration ); }
public async Task ShouldUpdateShooterAssociationInfoBeOkHavingProvidedData() { var existing = Scenario.ShooterAssociationInfos.FirstOrDefault(); //Conteggio gli elementi prima della creazione var countBefore = Scenario.ShooterAssociationInfos.Count; var existingAssociation = Scenario.Associations.FirstOrDefault(x => x.Id == existing.AssociationId); //Composizione della request var request = new ShooterAssociationInfoUpdateRequest { ShooterAssociationInfoId = existing.Id, AssociationId = existing.AssociationId, ShooterId = existing.ShooterId, RegistrationDate = RandomizationUtils.GetRandomDate(), SafetyOfficier = !existing.SafetyOfficier, CardNumber = RandomizationUtils.GenerateRandomString(5), Categories = new List <string> { existingAssociation.Categories.LastOrDefault() } }; //Invoke del metodo var response = await Controller.UpdateShooterAssociationInfo(request); //Conteggio gli elementi dopo la creazione var countAfter = Scenario.ShooterAssociationInfos.Count; //Parsing della risposta e assert var parsed = ParseExpectedOk <ShooterAssociationInfoContract>(response); Assert.AreEqual(countBefore, countAfter); Assert.IsTrue(parsed != null && parsed.Data.Association.AssociationId == request.AssociationId && parsed.Data.Shooter.ShooterId == request.ShooterId && parsed.Data.RegistrationDate == request.RegistrationDate && parsed.Data.SafetyOfficier == request.SafetyOfficier && parsed.Data.CardNumber == request.CardNumber && parsed.Data.Categories.All(x => request.Categories.Contains(x)) ); }