Esempio n. 1
0
        public void Parse_Positive(
            double widthA,
            double heightA,
            double widthB,
            double heightB,
            params string[] args
            )
        {
            // Arrange
            var expectedEnvelopes = new RectangularEnvelope[]
            {
                new RectangularEnvelope(widthA, heightA),
                new RectangularEnvelope(widthB, heightB)
            };

            // Act
            var actualEnvelopes = environment
                                  .Parse(args)
                                  .Cast <RectangularEnvelope>();

            var comparer = new RectangularEnvelopeEqualityComparer();

            // Assert
            Assert.Equal(expectedEnvelopes, actualEnvelopes, comparer);
        }
 public bool Analize(
     RectangularEnvelope envelopeA,
     RectangularEnvelope envelopeB
     )
 {
     return(envelopeA.IsLessThan(envelopeB) ||
            envelopeB.IsLessThan(envelopeA));
 }
Esempio n. 3
0
 public static bool IsLessThan(
     this RectangularEnvelope a,
     RectangularEnvelope b
     )
 {
     return((a.Width < b.Width) && (a.Height < b.Height) ||
            (a.Height < b.Width) && (a.Width < b.Height));
 }
        public void Ctor(double width, double height)
        {
            // Act
            var actualEnvelope = new RectangularEnvelope(width, height);

            // Assert
            Assert.Equal(width, actualEnvelope.Width);
            Assert.Equal(height, actualEnvelope.Height);
        }
Esempio n. 5
0
        public void RectangularEnvelopeAnalizer_CanAnalize()
        {
            // Arrange
            var rectangularEnvelope = new RectangularEnvelope(width: 0, height: 0);

            // Act
            var actualValue = analizer.CanAnalize(rectangularEnvelope);

            // Assert
            Assert.True(actualValue);
        }
Esempio n. 6
0
        public void IsLessThan_BToA_Negative(
            double widthA,
            double heightA,
            double widthB,
            double heightB)
        {
            // Arrange
            var envelopeA = new RectangularEnvelope(widthA, heightA);
            var envelopeB = new RectangularEnvelope(widthB, heightB);

            // Act
            var actualValue = envelopeB.IsLessThan(envelopeA);

            // Assert
            Assert.False(actualValue);
        }
Esempio n. 7
0
        public void IsLessThan_AToB_Positive(
            double widthA,
            double heightA,
            double widthB,
            double heightB)
        {
            // Arrange
            var envelopeA = new RectangularEnvelope(widthA, heightA);
            var envelopeB = new RectangularEnvelope(widthB, heightB);

            // Act
            var actualValue = envelopeA.IsLessThan(envelopeB);

            // Assert
            Assert.True(actualValue);
        }
        public void DoesFits_TryPutBigRectangular_False()
        {
            //arrange
            int length = 10;
            int height = 5;

            double radius = 5.5;
            var    small  = new RectangularEnvelope(length, height);
            var    big    = new RoundEnvelope(radius);
            bool   result;

            //act
            result = small.DoesFits(big);

            //assert
            Assert.IsFalse(result);
        }
        public void DoesFits_TryPutSmallRectangular_True()
        {
            //arrange
            int length = 10;
            int height = 5;

            double radius = 5.6;
            var    small  = new RectangularEnvelope(length, height);
            var    big    = new RoundEnvelope(radius);
            bool   result;

            //act
            result = big.DoesFits(small);

            //assert
            Assert.IsTrue(result);
        }
Esempio n. 10
0
        public void RectangularEnvelopeAnalizer_Analize_Negative(
            double widthA,
            double heightA,
            double widthB,
            double heightB
            )
        {
            // Arrange
            var envelopeA = new RectangularEnvelope(widthA, heightA);
            var envelopeB = new RectangularEnvelope(widthB, heightB);

            // Act
            var actualValue = analizer.Analize(envelopeA, envelopeB);

            // Assert
            Assert.False(actualValue);
        }
        public void DoesFits_TryPutBigToSmall_False()
        {
            //arrange
            int    length    = 10;
            int    height    = 5;
            double increaser = 0.1;

            var  small = new RectangularEnvelope(length, height);
            var  big   = new RectangularEnvelope(length + increaser, height + increaser);
            bool result;

            //act
            result = small.DoesFits(big);

            //assert
            Assert.IsFalse(result);
        }
        public void DoesFits_TryPutSmallToBig_True()
        {
            //arrange
            int    length    = 10;
            int    height    = 5;
            double increaser = 0.1;

            var  small = new RectangularEnvelope(length, height);
            var  big   = new RectangularEnvelope(length + increaser, height + increaser);
            bool result;

            //act
            result = big.DoesFits(small);

            //assert
            Assert.IsTrue(result);
        }
Esempio n. 13
0
        public void RequestExtraEnvelopes_Positive(
            string inputString,
            double widthA,
            double heightA,
            double widthB,
            double heightB
            )
        {
            // Arrange
            var expectedEnvelopes = new RectangularEnvelope[]
            {
                new RectangularEnvelope(widthA, heightA),
                new RectangularEnvelope(widthB, heightB)
            };

            var consoleUserResponses = new Queue <string>(
                new[]
            {
                "yEs",
                inputString
            }
                );

            mockConsoleManager
            .Setup(c => c.ReadLine())
            .Returns(() => consoleUserResponses.Dequeue());

            // Act
            var actualEnvelopes = environment
                                  .RequestExtraEnvelopes()
                                  .Cast <RectangularEnvelope>();

            var equalityComparer = new RectangularEnvelopeEqualityComparer();

            Assert.Equal(
                expectedEnvelopes,
                actualEnvelopes,
                equalityComparer);
        }