public void TheBuilderPatternShouldReturnAnObjectWithDefaultsAndValuesIfSomeValuesAreProvided() { var country = _builder.WithName(testName).WithLanguage(testLanguage).Build(); Assert.AreEqual(testName, country.Name); Assert.AreEqual(defaultString, country.Continent.Name); Assert.AreEqual(defaultString, country.Currency); Assert.AreEqual(testLanguage, country.Language); }
public void GivenCountryWhenValidatingThenRequiredRelationsMustExist() { var builder = new CountryBuilder(this.DatabaseSession); builder.Build(); Assert.IsTrue(this.DatabaseSession.Derive().HasErrors); builder.WithIsoCode("XX").Build(); builder.Build(); Assert.IsTrue(this.DatabaseSession.Derive().HasErrors); this.DatabaseSession.Rollback(); builder.WithName("X Country"); builder.Build(); Assert.IsFalse(this.DatabaseSession.Derive().HasErrors); this.DatabaseSession.Rollback(); builder = new CountryBuilder(this.DatabaseSession); builder.WithName("X Country"); builder.Build(); Assert.IsTrue(this.DatabaseSession.Derive().HasErrors); }
public void GivenCountryWhenValidatingThenRequiredRelationsMustExist() { var builder = new CountryBuilder(this.Session); builder.Build(); Assert.IsTrue(this.Session.Derive().HasErrors); builder.WithIsoCode("XX").Build(); builder.Build(); Assert.IsTrue(this.Session.Derive().HasErrors); this.Session.Rollback(); builder.WithName("X Country"); builder.Build(); Assert.IsFalse(this.Session.Derive().HasErrors); this.Session.Rollback(); builder = new CountryBuilder(this.Session); builder.WithName("X Country"); builder.Build(); Assert.IsTrue(this.Session.Derive().HasErrors); }