コード例 #1
0
        public void CreateValid_ReturnsOk()
        {
            //Arrange
            RationNumber value = new RationNumber(10, 2);

            //Assert
            Assert.NotNull(value);
        }
コード例 #2
0
        public void OperatorEquals_NullAndNotNull_ReturnsException()
        {
            //Arrange
            RationNumber valueA = null;
            RationNumber valueB = new RationNumber(11, 2);

            //Act
            //Assert
            Assert.Throws <NullReferenceException>(() => valueA == valueB);
        }
コード例 #3
0
        public void N10D3ConvertToInt_Returns3()
        {
            //Arrange
            RationNumber valueA = new RationNumber(10, 3);
            //Act
            var result = (float)valueA;

            //Assert
            Assert.Equal(expected: (int)(10 / 3), result);
        }
コード例 #4
0
        public void N2D3Decrement_ReturnsN1D2()
        {
            //Arrange
            RationNumber valueA = new RationNumber(2, 3);
            //Act
            var result = valueA--;

            //Assert
            Assert.Equal(expected: new RationNumber(1, 2), result);
        }
コード例 #5
0
        public void OperatorEquals_Nulls_ReturnsTrue()
        {
            //Arrange
            RationNumber valueA = null;
            RationNumber valueB = null;
            //Act
            bool result = valueA == valueB;

            //Assert
            Assert.True(result);
        }
コード例 #6
0
        public void N10D2DTakingRemainderN4D2_ReturnsN16D16()
        {
            //Arrange
            RationNumber valueA = new RationNumber(10, 2);
            RationNumber valueB = new RationNumber(4, 2);
            //Act
            var result = valueA % valueB;

            //Assert
            Assert.Equal(expected: new RationNumber(16, 16), result);
        }
コード例 #7
0
        public void Equals_ReturnsFalse()
        {
            //Arrange
            RationNumber valueA = new RationNumber(10, 2);
            RationNumber valueB = new RationNumber(11, 2);
            //Act
            bool result = valueA.Equals(valueB);

            //Assert
            Assert.False(result);
        }
コード例 #8
0
        public void N2D3DivisionN4D5_ReturnsN10D12()
        {
            //Arrange
            RationNumber valueA = new RationNumber(2, 3);
            RationNumber valueB = new RationNumber(4, 5);
            //Act
            var result = valueA / valueB;

            //Assert
            Assert.Equal(expected: new RationNumber(10, 12), result);
        }
コード例 #9
0
        public void OperatorNotEquals_NotNulls_ReturnsTrue()
        {
            //Arrange
            RationNumber valueA = new RationNumber(11, 2);
            RationNumber valueB = new RationNumber(12, 2);
            //Act
            bool result = valueA != valueB;

            //Assert
            Assert.True(result);
        }
コード例 #10
0
        public void N1D3LessOrEqualN1D3_ReturnsTrue()
        {
            //Arrange
            RationNumber valueA = new RationNumber(1, 3);
            RationNumber valueB = new RationNumber(1, 3);
            //Act
            bool result = valueA <= valueB;

            //Assert
            Assert.True(result);
        }
コード例 #11
0
        public void N1D2GreaterOrEqualN1D2_ReturnsTrue()
        {
            //Arrange
            RationNumber valueA = new RationNumber(1, 2);
            RationNumber valueB = new RationNumber(1, 2);
            //Act
            bool result = valueA >= valueB;

            //Assert
            Assert.True(result);
        }
コード例 #12
0
        public void N1D3LessN1D3_ReturnsFalse()
        {
            //Arrange
            RationNumber valueA = new RationNumber(1, 3);
            RationNumber valueB = new RationNumber(1, 3);
            //Act
            bool result = valueA < valueB;

            //Assert
            Assert.False(result);
        }
コード例 #13
0
        public void N1D2GreaterN1D2_ReturnsFalse()
        {
            //Arrange
            RationNumber valueA = new RationNumber(1, 2);
            RationNumber valueB = new RationNumber(1, 2);
            //Act
            bool result = valueA > valueB;

            //Assert
            Assert.False(result);
        }
コード例 #14
0
        public void N1D3MinusN1D4_ReturnsN1D12()
        {
            //Arrange
            RationNumber valueA = new RationNumber(1, 3);
            RationNumber valueB = new RationNumber(1, 4);
            //Act
            var result = valueA - valueB;

            //Assert
            Assert.Equal(expected: new RationNumber(1, 12), result);
        }
コード例 #15
0
        public void N1D2MinusN1D2_ReturnsN0D2()
        {
            //Arrange
            RationNumber valueA = new RationNumber(1, 2);
            RationNumber valueB = new RationNumber(1, 2);
            //Act
            var result = valueA - valueB;

            //Assert
            Assert.Equal(expected: new RationNumber(0, 2), result);
        }
コード例 #16
0
        public void N1D2MultiplicationN4D5_ReturnsN4D10()
        {
            //Arrange
            RationNumber valueA = new RationNumber(1, 2);
            RationNumber valueB = new RationNumber(4, 5);
            //Act
            var result = valueA * valueB;

            //Assert
            Assert.Equal(expected: new RationNumber(4, 10), result);
        }
コード例 #17
0
        public void OperatorEquals_NotNullAndNull_ReturnsFalse()
        {
            //Arrange
            RationNumber valueA = new RationNumber(11, 2);
            RationNumber valueB = null;
            //Act
            bool result = valueA == valueB;

            //Assert
            Assert.False(result);
        }
コード例 #18
0
        public void OperatorNotEquals_ReturnsFalse()
        {
            //Arrange
            RationNumber valueA = new RationNumber(10, 2);
            RationNumber valueB = new RationNumber(10, 2);
            //Act
            bool result = valueA != valueB;

            //Assert
            Assert.False(result);
        }