Esempio n. 1
0
        public async Task CreateBeneficiary_WithRandomValidRequest_ShouldPersistCorrectly()
        {
            // Arrange

            var createBeneficiaryRequest = new CreateBeneficiaryRequest
            {
                FirstName      = _faker.Name.FirstName(),
                LastName       = _faker.Name.LastName(),
                Type           = BeneficiaryType.Individual,
                OrganizerId    = Guid.NewGuid().ToString(),
                CountryIsoCode = CountryCode.Bg,
                City           = City.Varna,
                Email          = _faker.Internet.Email(),
                Phone          = _faker.Phone.PhoneNumber(),
                Website        = _faker.Internet.Url()
            };

            // Act

            var createBeneficiaryResponse = await _campaignsService.CreateBeneficiary(
                createBeneficiaryRequest, Mock.Of <ServerCallContext>());

            // Assert

            createBeneficiaryResponse.Should().NotBeNull();

            var beneficiaryFromDb = await _appDbContext.Beneficiaries.FindAsync(Guid.Parse(createBeneficiaryResponse.Id));

            beneficiaryFromDb.FirstName.Should().Be(createBeneficiaryRequest.FirstName);
            beneficiaryFromDb.LastName.Should().Be(createBeneficiaryRequest.LastName);
            beneficiaryFromDb.Type.Should().Be(createBeneficiaryRequest.Type);
            beneficiaryFromDb.OrganizerId.ToString().Should().Be(createBeneficiaryRequest.OrganizerId);
            beneficiaryFromDb.ISO2CountryCode.Should().Be(createBeneficiaryRequest.CountryIsoCode);
            beneficiaryFromDb.City.Should().Be(createBeneficiaryRequest.City);
        }
Esempio n. 2
0
 public override Task <CreateBeneficiaryResponse> CreateBeneficiary(CreateBeneficiaryRequest request, ServerCallContext context)
 {
     return(_mediator.Send(new CreateBeneficiaryCommand(request)));
 }