public void CreateConverter_BaseUnitToDirectAnchestor_CallsCreateConverterOnce() { // Arrange var mockDelegate = CreateMockDelegate(); IDimension mass = CreateStubDimension("M"); IUnit kg = CreateStubUnit("kg", mass); IUnit lbs = CreateStubUnit("lbs", mass); DimensionContainer container = new DimensionContainer(mass, mockDelegate.Object.Create); container.SetBaseUnit(kg); container.AddUnit(kg, lbs); // Act IValueConverter converter = container.CreateConverter(kg, lbs); // Assert mockDelegate.Verify(x => x.Create(kg, lbs), Times.Once()); Assert.NotNull(converter); }
public void CreateConverter_UnitToAnchestor_CallsCreateConverterTwice() { // Arrange var mockDelegate = CreateMockDelegate(); IDimension mass = CreateStubDimension("M"); IUnit g = CreateStubUnit("g", mass); IUnit kg = CreateStubUnit("kg", mass); IUnit lbs = CreateStubUnit("lbs", mass); DimensionContainer container = new DimensionContainer(mass, mockDelegate.Object.Create); container.SetBaseUnit(g); container.AddUnit(g, kg); container.AddUnit(kg, lbs); // Act IValueConverter converter = container.CreateConverter(kg, lbs); // Assert mockDelegate.Verify(x => x.Create(It.IsAny <IUnit>(), It.IsAny <IUnit>()), Times.Exactly(1)); Assert.NotNull(converter); }