Exemple #1
0
            public async void Should_return_nullexception_when_address_is_null()
            {
                // Arrange
                Address address           = null;
                int     userId            = 1;
                var     DbContextInMemory = GetInMemoryDbContext();
                var     LoggerMock        = new Mock <ILogger <UserAddressRepository> >();
                var     UserAddressRepositoryUnderTest = new UserAddressRepository(DbContextInMemory, Mapper, LoggerMock.Object);

                //Act
                var result = UserAddressRepositoryUnderTest.CreateAsync(userId, address);

                //Assert
                await Assert.ThrowsAsync <ArgumentNullException>(async() => await result);
            }
Exemple #2
0
            public async void Should_return_object_when_address_created()
            {
                int     userId            = 1;
                var     DbContextInMemory = GetInMemoryDbContext();
                var     LoggerMock        = new Mock <ILogger <UserAddressRepository> >();
                var     UserAddressRepositoryUnderTest = new UserAddressRepository(DbContextInMemory, Mapper, LoggerMock.Object);
                Address address      = UserDataEntity;
                var     resultObject = new Address
                {
                    Address1    = "1601 Hood Avenue",
                    Address2    = "dolore in adipisicing et",
                    City        = "San Diego",
                    CountryCode = "11",
                    PinCode     = "92103",
                    StateId     = 1,
                    IsVerified  = false
                };

                //Act
                var result = await UserAddressRepositoryUnderTest.CreateAsync(userId, address);

                //Assert
                Assert.Equal(resultObject.Address1, GetValue("Address1"));
                Assert.Equal(resultObject.Address2, GetValue("Address2"));
                Assert.Equal(resultObject.City, GetValue("City"));
                Assert.Equal(resultObject.CountryCode, GetValue("CountryCode"));
                Assert.Equal(resultObject.PinCode, GetValue("PinCode"));
                Assert.Equal(resultObject.StateId, GetValue("StateId"));
                Assert.Equal(resultObject.IsVerified, GetValue("IsVerified"));


                object GetValue(string Name)
                {
                    return(result.GetType().GetProperty(Name).GetValue(result));
                }
            }