示例#1
0
        public void CompareTest_SortCollectionAcordingObservationPointComparer_RightOrderOnCollection()
        {
            // Arange
            var sutComparer = new ObservationPointComparer <IEnergyObservation>();

            var energyMock1 = GetEnergyObservationMock(2, 2);
            var energyMock2 = GetEnergyObservationMock(1, 1);
            var energyMock3 = GetEnergyObservationMock(-0.01, 1);
            var energyMock4 = GetEnergyObservationMock(-0.1, 1);

            var listActual   = new List <IEnergyObservation>();
            var listExpected = new List <IEnergyObservation>();

            listActual.Add(energyMock1.Object);
            listActual.Add(energyMock2.Object);
            listActual.Add(energyMock3.Object);
            listActual.Add(energyMock4.Object);

            listExpected.Add(energyMock4.Object);
            listExpected.Add(energyMock3.Object);
            listExpected.Add(energyMock2.Object);
            listExpected.Add(energyMock1.Object);

            // Act
            listActual.Sort(sutComparer);

            // Assert
            Assert.Equal(listExpected, listActual);
        }
示例#2
0
        public void ComparerTest_SecondObservationIsNull_ResultIs1()
        {
            // Arange
            var sut        = new ObservationPointComparer <IEnergyObservation>();
            var energyMock = new Mock <IEnergyObservation>();

            // Act
            var actualResult = sut.Compare(energyMock.Object, null);

            // Assert
            Assert.Equal(1, actualResult);
        }
示例#3
0
        public void ComparerTest_FirstObservationIsNull_ResultIsMinus1()
        {
            // Arange
            var sut        = new ObservationPointComparer <IEnergyObservation>();
            var energyMock = new Mock <IEnergyObservation>();

            // Act
            var actualResult = sut.Compare(null, energyMock.Object);

            // Assert
            Assert.Equal(-1, actualResult);
        }
示例#4
0
        public void ComparerTest_ObservationReferencesAreEqual_ResultIs0()
        {
            // Arange
            var sut         = new ObservationPointComparer <IEnergyObservation>();
            var energyMock1 = new Mock <IEnergyObservation>();
            var energyMock2 = energyMock1;

            // Act
            var actualResult = sut.Compare(energyMock1.Object, energyMock2.Object);

            // Assert
            Assert.Equal(0, actualResult);
        }
示例#5
0
        public void CompareTest_PassTwoEnergyObservation_Return1OrMinus1Or0
            (double xCoordinate1, double yCoordinate1,
            double xCoordinate2, double yCoordinate2, int expectedResult)
        {
            // Arange
            var sut         = new ObservationPointComparer <IEnergyObservation>();
            var energyMock1 = GetEnergyObservationMock(xCoordinate1, yCoordinate1);
            var energyMock2 = GetEnergyObservationMock(xCoordinate2, yCoordinate2);


            // Act
            var actualResult = sut.Compare(energyMock1.Object, energyMock2.Object);

            // Assert
            Assert.Equal(expectedResult, actualResult);
        }
示例#6
0
 public ObservationPointComparerTests()
 {
     _observationPointComparer = new ObservationPointComparer(_coordinatesComparerMock.Object);
 }