public void ToDomain_WhenCommandIsEmpty_ReturnsNull() { IAddressCommand sut = CreateSut(false, hasStreetLine2: false, hasPostalCode: false, hasCity: false, hasState: false, hasCountry: false); IAddress result = sut.ToDomain(); Assert.That(result, Is.Null); }
public void IsEmpty_WhenCommandHasValueInCountry_ReturnsFalse() { IAddressCommand sut = CreateSut(hasCountry: true); bool result = sut.IsEmpty(); Assert.That(result, Is.False); }
public void ToDomain_WhenCommandDoesNotHavePostalCode_ReturnsAddressWithoutPostalCode() { IAddressCommand sut = CreateSut(hasPostalCode: false); string result = sut.ToDomain().PostalCode; Assert.That(result, Is.Null); }
public void ToDomain_WhenCommandDoesNotHaveStreetLine2_ReturnsAddressWithoutStreetLine2() { IAddressCommand sut = CreateSut(hasStreetLine2: false); string result = sut.ToDomain().StreetLine2; Assert.That(result, Is.Null); }
public void IsEmpty_WhenCommandHasValueInStreetLine1_ReturnsFalse() { IAddressCommand sut = CreateSut(true); bool result = sut.IsEmpty(); Assert.That(result, Is.False); }
public void Validate_WhenCalled_ReturnsValidator() { IAddressCommand sut = CreateSut(); IValidator result = sut.Validate(_validatorMockContext.ValidatorMock.Object); Assert.That(result, Is.EqualTo(_validatorMockContext.ValidatorMock.Object)); }
public void ToDomain_WhenCommandDoesNotHaveCountry_ReturnsAddressWithoutCountry() { IAddressCommand sut = CreateSut(hasCountry: false); string result = sut.ToDomain().Country; Assert.That(result, Is.Null); }
public void Validate_WhenValidatorIsNull_ThrowsArgumentNullException() { IAddressCommand sut = CreateSut(); ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.Validate(null)); Assert.That(result.ParamName, Is.EqualTo("validator")); }
public void IsEmpty_WhenCommandDoesNotHaveValueInAnyProperties_ReturnsTrue() { IAddressCommand sut = CreateSut(); bool result = sut.IsEmpty(); Assert.That(result, Is.True); }
public void ToDomain_WhenCommandIsNotEmpty_ReturnsAddress() { IAddressCommand sut = CreateSut(); IAddress result = sut.ToDomain(); Assert.That(result, Is.TypeOf <Address>()); }
public void ToDomain_WhenCommandHasAddressCommandWhichAreEmpty_ReturnsContactWithEmptyAddress() { IAddressCommand addressCommand = CreateAddressCommandMock(true).Object; IContactDataCommand sut = CreateSut(addressCommand: addressCommand); IAddress result = sut.ToDomain(_contactRepositoryMock.Object, _accountingRepositoryMock.Object).Address; Assert.That(result.DisplayAddress, Is.EqualTo(string.Empty)); }
public void ToDomain_WhenCommandHasStreetLine2_ReturnsAddressWithStreetLine2FromCommand() { string streetLine2 = _fixture.Create <string>(); IAddressCommand sut = CreateSut(streetLine2: streetLine2); string result = sut.ToDomain().StreetLine2; Assert.That(result, Is.EqualTo(streetLine2)); }
public void ToDomain_WhenCommandHasCountry_ReturnsAddressWithCountryFromCommand() { string country = _fixture.Create <string>(); IAddressCommand sut = CreateSut(country: country); string result = sut.ToDomain().Country; Assert.That(result, Is.EqualTo(country)); }
public void ToDomain_WhenCommandHasState_ReturnsAddressWithStateFromCommand() { string state = _fixture.Create <string>(); IAddressCommand sut = CreateSut(state: state); string result = sut.ToDomain().State; Assert.That(result, Is.EqualTo(state)); }
public void ToDomain_WhenCommandHasPostalCode_ReturnsAddressWithPostalCodeFromCommand() { string postalCode = _fixture.Create <string>(); IAddressCommand sut = CreateSut(postalCode: postalCode); string result = sut.ToDomain().PostalCode; Assert.That(result, Is.EqualTo(postalCode)); }
public void ToDomain_WhenCommandHasAddressCommandWhichAreNotEmpty_ReturnsContactWithValueFromToDomainOnAddressCommand() { IAddress address = _fixture.BuildAddressMock().Object; IAddressCommand addressCommand = CreateAddressCommandMock(address: address).Object; IContactDataCommand sut = CreateSut(addressCommand: addressCommand); IAddress result = sut.ToDomain(_contactRepositoryMock.Object, _accountingRepositoryMock.Object).Address; Assert.That(result, Is.EqualTo(address)); }
public void Validate_WhenCalled_AssertShouldHaveMaxLengthWasCalledOnStringValidatorForPostalCode() { string postalCode = _fixture.Create <string>(); IAddressCommand sut = CreateSut(postalCode: postalCode); sut.Validate(_validatorMockContext.ValidatorMock.Object); _validatorMockContext.StringValidatorMock.Verify(m => m.ShouldHaveMaxLength( It.Is <string>(value => string.CompareOrdinal(value, postalCode) == 0), It.Is <int>(value => value == 16), It.Is <Type>(value => value == sut.GetType()), It.Is <string>(value => string.CompareOrdinal(value, "PostalCode") == 0), It.Is <bool>(value => value)), Times.Once); }
public void Validate_WhenCalled_AssertShouldHaveMinLengthWasCalledOnStringValidatorForStreetLine2() { string streetLine2 = _fixture.Create <string>(); IAddressCommand sut = CreateSut(streetLine2: streetLine2); sut.Validate(_validatorMockContext.ValidatorMock.Object); _validatorMockContext.StringValidatorMock.Verify(m => m.ShouldHaveMinLength( It.Is <string>(value => string.CompareOrdinal(value, streetLine2) == 0), It.Is <int>(value => value == 1), It.Is <Type>(value => value == sut.GetType()), It.Is <string>(value => string.CompareOrdinal(value, "StreetLine2") == 0), It.Is <bool>(value => value)), Times.Once); }
public void Validate_WhenCalled_AssertShouldMatchPatternWasCalledOnStringValidatorForPostalCode() { string postalCode = _fixture.Create <string>(); IAddressCommand sut = CreateSut(postalCode: postalCode); sut.Validate(_validatorMockContext.ValidatorMock.Object); _validatorMockContext.StringValidatorMock.Verify(m => m.ShouldMatchPattern( It.Is <string>(value => string.CompareOrdinal(value, postalCode) == 0), It.Is <Regex>(value => string.CompareOrdinal(value.ToString(), RegexTestHelper.PostalCodeRegexPattern) == 0), It.Is <Type>(value => value == sut.GetType()), It.Is <string>(value => string.CompareOrdinal(value, "PostalCode") == 0), It.Is <bool>(value => value)), Times.Once); }
private ICompanyCommand CreateSut(ICompanyNameCommand companyNameCommand = null, bool hasAddressCommand = true, IAddressCommand addressCommand = null, bool hasPrimaryPhone = true, string primaryPhone = null, bool hasSecondaryPhone = true, string secondaryPhone = null, bool hasHomePage = true, string homePage = null) { return(_fixture.Build <BusinessLogic.Contacts.Commands.CompanyCommand>() .With(m => m.Name, companyNameCommand ?? CreateCompanyNameCommandMock().Object) .With(m => m.Address, hasAddressCommand ? addressCommand ?? CreateAddressCommandMock().Object : null) .With(m => m.PrimaryPhone, hasPrimaryPhone ? primaryPhone ?? _fixture.Create <string>() : null) .With(m => m.SecondaryPhone, hasSecondaryPhone ? secondaryPhone ?? _fixture.Create <string>() : null) .With(m => m.HomePage, hasHomePage ? homePage ?? _fixture.Create <string>() : null) .Create()); }
private IContactDataCommand CreateSut(bool hasNameCommand = true, INameCommand nameCommand = null, bool hasAddressCommand = true, IAddressCommand addressCommand = null, string homePhone = null, string mobilePhone = null, bool hasBirthday = true, DateTime?birthday = null, string mailAddress = null, bool hasCompanyCommand = true, ICompanyCommand companyCommand = null, int?contactGroupIdentifier = null, string acquaintance = null, string personalHomePage = null, int?lendingLimit = null, int?paymentTermIdentifier = null) { return(_fixture.Build <Sut>() .With(m => m.Name, hasNameCommand ? nameCommand ?? CreateNameCommandMock().Object : null) .With(m => m.Address, hasAddressCommand ? addressCommand ?? CreateAddressCommandMock().Object : null) .With(m => m.HomePhone, homePhone ?? _fixture.Create <string>()) .With(m => m.MobilePhone, mobilePhone ?? _fixture.Create <string>()) .With(m => m.Birthday, hasBirthday ? birthday ?? _fixture.Create <DateTime>() : (DateTime?)null) .With(m => m.MailAddress, mailAddress ?? _fixture.Create <string>()) .With(m => m.Company, hasCompanyCommand ? companyCommand ?? CreateCompanyCommandMock().Object : null) .With(m => m.ContactGroupIdentifier, contactGroupIdentifier ?? _fixture.Create <int>()) .With(m => m.Acquaintance, acquaintance ?? _fixture.Create <string>()) .With(m => m.PersonalHomePage, personalHomePage ?? _fixture.Create <string>()) .With(m => m.LendingLimit, lendingLimit ?? _fixture.Create <int>()) .With(m => m.PaymentTermIdentifier, paymentTermIdentifier ?? _fixture.Create <int>()) .Create()); }
private IContactDataCommand CreateSut(INameCommand nameCommand = null, bool hasAddressCommand = true, IAddressCommand addressCommand = null, bool hasHomePhone = true, string homePhone = null, bool hasMobilePhone = true, string mobilePhone = null, bool hasBirthday = true, DateTime?birthday = null, bool hasMailAddress = true, string mailAddress = null, bool hasCompanyCommand = true, ICompanyCommand companyCommand = null, int?contactGroupIdentifier = null, IContactGroup contactGroup = null, int?paymentTermIdentifier = null, bool hasAcquaintance = true, string acquaintance = null, bool hasPersonalHomePage = true, string personalHomePage = null, int?lendingLimit = null, IPaymentTerm paymentTerm = null) { _contactRepositoryMock.Setup(m => m.GetContactGroupAsync(It.IsAny <int>())) .Returns(Task.Run(() => contactGroup ?? _fixture.BuildContactGroupMock().Object)); _accountingRepositoryMock.Setup(m => m.GetPaymentTermAsync(It.IsAny <int>())) .Returns(Task.Run(() => paymentTerm ?? _fixture.BuildPaymentTermMock().Object)); return(_fixture.Build <Sut>() .With(m => m.Name, nameCommand ?? CreateNameCommandMock().Object) .With(m => m.Address, hasAddressCommand ? addressCommand ?? CreateAddressCommandMock().Object : null) .With(m => m.HomePhone, hasHomePhone ? homePhone ?? _fixture.Create <string>() : null) .With(m => m.MobilePhone, hasMobilePhone ? mobilePhone ?? _fixture.Create <string>() : null) .With(m => m.Birthday, hasBirthday ? birthday ?? _fixture.Create <DateTime>() : (DateTime?)null) .With(m => m.MailAddress, hasMailAddress ? mailAddress ?? _fixture.Create <string>() : null) .With(m => m.Company, hasCompanyCommand ? companyCommand ?? CreateCompanyCommandMock().Object : null) .With(m => m.ContactGroupIdentifier, contactGroupIdentifier ?? _fixture.Create <int>()) .With(m => m.Acquaintance, hasAcquaintance ? acquaintance ?? _fixture.Create <string>() : null) .With(m => m.PersonalHomePage, hasPersonalHomePage ? personalHomePage ?? _fixture.Create <string>() : null) .With(m => m.LendingLimit, lendingLimit ?? _fixture.Create <int>()) .With(m => m.PaymentTermIdentifier, paymentTermIdentifier ?? _fixture.Create <int>()) .Create()); }