Exemplo n.º 1
0
        public void Clone_NonEmptyContainer_ReturnsContainerWithSameUnits()
        {
            // Arrange
            var        mockDelegate = CreateMockDelegate();
            IDimension mass         = CreateStubDimension("M");
            IUnit      g            = CreateStubUnit("g", mass);
            IUnit      kg           = CreateStubUnit("kg", mass);
            IUnit      lbs          = CreateStubUnit("lbs", mass);

            DimensionContainer original = new DimensionContainer(mass, mockDelegate.Object.Create);

            original.SetBaseUnit(g);
            original.AddUnit(g, kg);
            original.AddUnit(g, lbs);

            // Act
            DimensionContainer cloned = (DimensionContainer)original.Clone();

            // Assert
            Assert.AreSame(original.BaseUnit, cloned.BaseUnit);
            CollectionAssert.AreEquivalent(original.Units, cloned.Units);
            Assert.True(cloned.CanConvert(g, kg));
            Assert.True(cloned.CanConvert(g, lbs));
            Assert.True(cloned.CanConvert(kg, lbs));
        }
Exemplo n.º 2
0
        public void Clone_EmptyContainer_ReturnsEmptyContainer()
        {
            // Arrange
            var                mockDelegate = CreateMockDelegate();
            IDimension         dimension    = CreateStubDimension();
            DimensionContainer original     = new DimensionContainer(dimension, mockDelegate.Object.Create);

            // Act
            DimensionContainer cloned = (DimensionContainer)original.Clone();

            // Assert
            Assert.NotNull(cloned);
            Assert.AreSame(original.Dimension, cloned.Dimension);
        }