public void TestObjectEquals() { Object id0 = new BarId(); Object id1 = new BarId(Guid.Parse("83b8710937a84b818c829162c1b405b6")); Object id2 = new BarId(Guid.Parse("83B8710937A84B818C829162C1B405B6")); Object id3 = new BarId(Guid.Parse("5A1DF7E2450B4BE7B4F970A95D391316")); Object id4 = null; Check.That(id0.Equals(id0)).IsTrue(); Check.That(id0.Equals(id1)).IsFalse(); Check.That(id0.Equals(id2)).IsFalse(); Check.That(id0.Equals(id3)).IsFalse(); Check.That(id0.Equals(id4)).IsFalse(); Check.That(id1.Equals(id1)).IsTrue(); Check.That(id1.Equals(id2)).IsTrue(); Check.That(id1.Equals(id3)).IsFalse(); Check.That(id1.Equals(id4)).IsFalse(); Check.That(id2.Equals(id2)).IsTrue(); Check.That(id2.Equals(id3)).IsFalse(); Check.That(id2.Equals(id4)).IsFalse(); Check.That(id3.Equals(id3)).IsTrue(); Check.That(id3.Equals(id4)).IsFalse(); }
public void Succeed_With_Name() { var id = new BarId(Guid.Parse("83b8710937a84b818c829162c1b405b6")); Check.That(id.Guid).IsEqualTo(Guid.Parse("83b8710937a84b818c829162c1b405b6")); Check.That(id.ToString()).IsEqualTo("{83B87109-37A8-4B81-8C82-9162C1B405B6}"); Check.That(id.GetHashCode()).Not.IsEqualTo(0); Check.That(id.DebuggerDisplay).IsEqualTo("{83B87109-37A8-4B81-8C82-9162C1B405B6}"); }
public void Succeed_With_DefaultConstructor() { var id = new BarId(); Check.That(id.Guid).IsEqualTo(Guid.Empty); Check.That(id.ToString()).IsEqualTo("{00000000-0000-0000-0000-000000000000}"); Check.That(id.GetHashCode()).IsEqualTo(0); Check.That(id.DebuggerDisplay).IsEqualTo("{00000000-0000-0000-0000-000000000000}"); }
public void Construction() { // arrange var drinkId = new DrinkId(Guid.NewGuid()); var barId = new BarId(Guid.NewGuid()); var drink = new Drink(drinkId, barId); var recipe = new Recipe(Array.Empty <Ingredient>(), Array.Empty <String>()); // assert Check.That(drink.Id).IsEqualTo(drinkId); Check.That(drink.BarId).IsEqualTo(barId); Check.That(drink.Name).IsNull(); Check.That(drink.Teaser).IsNull(); Check.That(drink.Description).IsNull(); Check.That(drink.ImageId).IsEqualTo(new ImageId()); Check.That(drink.Recipe).IsNull(); Check.That(drink.Tags).IsEmpty(); Check.That(drink.Glass).IsNull(); Check.That(drink.Ice).IsNull(); Check.That(drink.Garnish).IsNull(); // act drink.SetName("Mai Tai") .SetTeaser("Lime, Orgeat, Rum") .SetDescription("The Mai Tai is a cocktail based on rum...") .SetRecipe(recipe) .SetTags(new[] { "sweet", "exotic" }) .SetGlass("Martini Glas") .SetIce("Cubed") .SetGarnish("Lemon twist"); // assert Check.That(drink.Id).IsEqualTo(drinkId); Check.That(drink.BarId).IsEqualTo(barId); Check.That(drink.Name).IsEqualTo("Mai Tai"); Check.That(drink.Teaser).IsEqualTo("Lime, Orgeat, Rum"); Check.That(drink.Description).IsEqualTo("The Mai Tai is a cocktail based on rum..."); Check.That(drink.ImageId).IsEqualTo(new ImageId()); Check.That(drink.Recipe).IsSameReferenceAs(recipe); Check.That(drink.Tags).ContainsExactly("sweet", "exotic"); Check.That(drink.Glass).IsEqualTo("Martini Glas"); Check.That(drink.Ice).IsEqualTo("Cubed"); Check.That(drink.Garnish).IsEqualTo("Lemon twist"); }
public void TestGetHashCode() { var id0 = new BarId(); var id1 = new BarId(Guid.Parse("83b8710937a84b818c829162c1b405b6")); var id2 = new BarId(Guid.Parse("83B8710937A84B818C829162C1B405B6")); var id3 = new BarId(Guid.Parse("5A1DF7E2450B4BE7B4F970A95D391316")); Check.That(id0.GetHashCode()).IsEqualTo(0); Check.That(id0.GetHashCode()).IsEqualTo(id0.GetHashCode()); Check.That(id0.GetHashCode()).IsNotEqualTo(id1.GetHashCode()); Check.That(id0.GetHashCode()).IsNotEqualTo(id2.GetHashCode()); Check.That(id0.GetHashCode()).IsNotEqualTo(id3.GetHashCode()); Check.That(id1.GetHashCode()).IsEqualTo(id1.GetHashCode()); Check.That(id1.GetHashCode()).IsEqualTo(id2.GetHashCode()); Check.That(id1.GetHashCode()).IsNotEqualTo(id3.GetHashCode()); Check.That(id2.GetHashCode()).IsEqualTo(id2.GetHashCode()); Check.That(id2.GetHashCode()).IsNotEqualTo(id3.GetHashCode()); Check.That(id3.GetHashCode()).IsEqualTo(id3.GetHashCode()); }
public void TestOperatorUnequal() { var id0 = new BarId(); var id1 = new BarId(Guid.Parse("83b8710937a84b818c829162c1b405b6")); var id2 = new BarId(Guid.Parse("83B8710937A84B818C829162C1B405B6")); var id3 = new BarId(Guid.Parse("5A1DF7E2450B4BE7B4F970A95D391316")); #pragma warning disable 1718 Check.That(id0 != id0).Not.IsTrue(); Check.That(id0 != id1).Not.IsFalse(); Check.That(id0 != id2).Not.IsFalse(); Check.That(id0 != id3).Not.IsFalse(); Check.That(id1 != id1).Not.IsTrue(); Check.That(id1 != id2).Not.IsTrue(); Check.That(id1 != id3).Not.IsFalse(); Check.That(id2 != id2).Not.IsTrue(); Check.That(id2 != id3).Not.IsFalse(); Check.That(id3 != id3).Not.IsTrue(); #pragma warning restore 1718 }
/// <summary> /// Initializes a new instance. /// </summary> public Drink(DrinkId drinkId, BarId barId) : base(drinkId) { BarId = barId; }
public void ReturnsFormatted_For_CustomGuid() { var id = new BarId(Guid.Parse("83b8710937a84b818c829162c1b405b6")); Check.That(id.DebuggerDisplay).IsEqualTo("{83B87109-37A8-4B81-8C82-9162C1B405B6}"); }
public void ReturnsZeros_For_DefaultConstructor() { var id = new BarId(); Check.That(id.DebuggerDisplay).IsEqualTo("{00000000-0000-0000-0000-000000000000}"); }
public void ReturnsZeros_For_DefaultConstructor() { var id = new BarId(); Check.That(id.ToString()).IsEqualTo("{00000000-0000-0000-0000-000000000000}"); }
public void ReturnsEmptyGuid_For_DefaultConstructor() { var id = new BarId(); Check.That(id.Guid).IsEqualTo(Guid.Empty); }