public void ConvertToWillReturnCorrectResult() { // Fixture setup var fixture = new CurrencyFixture(); fixture.Register(() => new Mock <IPrincipal>().Object); var sut = fixture.CreateAnonymous <Basket>(); fixture.AddManyTo(sut.Contents); var currency = fixture.CreateAnonymous <Currency>(); var expectedContents = (from x in sut.Contents let convertedProduct = x.Product.ConvertTo(currency) select new Likeness <Extent, Extent>(x) .With(d => d.Product).EqualsWhen((s, d) => new Likeness <Product, Product>(convertedProduct).Equals(d.Product)) .Without(d => d.Total) .Without(d => d.Updated)) .ToList(); // Exercise system Basket result = sut.ConvertTo(currency); // Verify outcome Assert.True(expectedContents.Cast <object>().SequenceEqual(result.Contents.Cast <object>())); // Teardown }
public void ConvertWillReturnCorrectResult() { // Fixture setup var fixture = new CurrencyFixture(); var currency = fixture.CreateAnonymous <Currency>(); var sut = fixture.CreateAnonymous <Product>(); var expectedProduct = new Likeness <Product, Product>(sut.WithUnitPrice(sut.UnitPrice.ConvertTo(currency))); // Exercise system Product result = sut.ConvertTo(currency); // Verify outcome Assert.True(expectedProduct.Equals(result)); // Teardown }
public void ConvertToNullWillThrow() { // Fixture setup var fixture = new CurrencyFixture(); fixture.Register(() => new Mock<IPrincipal>().Object); var sut = fixture.CreateAnonymous<Basket>(); fixture.AddManyTo(sut.Contents); Currency nullCurrency = null; // Exercise system and verify outcome Assert.Throws<ArgumentNullException>(() => sut.ConvertTo(nullCurrency)); // Teardown }
public void ConvertToNullWillThrow() { // Fixture setup var fixture = new CurrencyFixture(); fixture.Register(() => new Mock <IPrincipal>().Object); var sut = fixture.CreateAnonymous <Basket>(); fixture.AddManyTo(sut.Contents); Currency nullCurrency = null; // Exercise system and verify outcome Assert.Throws <ArgumentNullException>(() => sut.ConvertTo(nullCurrency)); // Teardown }
public void ConvertToWillReturnCorrectResult() { // Fixture setup var fixture = new CurrencyFixture(); fixture.Register(() => new Mock<IPrincipal>().Object); var sut = fixture.CreateAnonymous<Basket>(); fixture.AddManyTo(sut.Contents); var currency = fixture.CreateAnonymous<Currency>(); var expectedContents = (from x in sut.Contents let convertedProduct = x.Product.ConvertTo(currency) select new Likeness<Extent, Extent>(x) .With(d => d.Product).EqualsWhen((s, d) => new Likeness<Product, Product>(convertedProduct).Equals(d.Product)) .Without(d => d.Total) .Without(d => d.Updated)) .ToList(); // Exercise system Basket result = sut.ConvertTo(currency); // Verify outcome Assert.True(expectedContents.Cast<object>().SequenceEqual(result.Contents.Cast<object>())); // Teardown }
public void ConvertWillReturnCorrectResult() { // Fixture setup var fixture = new CurrencyFixture(); var currency = fixture.CreateAnonymous<Currency>(); var sut = fixture.CreateAnonymous<EvaluatedProduct>(); var expectedProduct = new Likeness(sut.WithUnitPrice(sut.UnitPrice.ConvertTo(currency))); // Exercise system EvaluatedProduct result = sut.ConvertTo(currency); // Verify outcome Assert.AreEqual(expectedProduct, result, "ConvertTo"); // Teardown }