Beispiel #1
0
        public async Task SaveShouldAddANewAddressGiverNonExistingEntry()
        {
            using var scope = ServiceProvider.CreateScope();
            var sut        = scope.ServiceProvider.GetRequiredService <IAddressRepository>();
            var unitOfWork = scope.ServiceProvider.GetRequiredService <IUnitOfWork>();
            var context    = scope.ServiceProvider.GetRequiredService <ApplicationContext>();

            var address = AddressFixture.GetDummyAddress();
            await sut.SaveAsync(address);

            var savedChanges = await unitOfWork.SaveChangesAsync();

            var savedAddress = await context.Addresses.FirstAsync();

            Assert.True(savedChanges);
            AssertDummyAddress(savedAddress);
            Assert.NotEqual(default, savedAddress.Uuid);
        public async Task SaveShouldAddANewAddressGivenNonExistingEntry()
        {
            using var scope = ServiceProvider.CreateScope();
            var sut        = scope.ServiceProvider.GetRequiredService <IAddressService>();
            var unitOfWork = scope.ServiceProvider.GetRequiredService <IUnitOfWork>();
            var context    = scope.ServiceProvider.GetRequiredService <ApplicationContext>();

            var address = AddressFixture.GetDummyAddress();

            var result = await sut.SaveAsync(address);

            await unitOfWork.SaveChangesAsync();

            Assert.True(result.IsSuccessful);
            Assert.NotEmpty(context.Addresses);
            Assert.Equal(1, context.Addresses.Count());
        }