コード例 #1
0
ファイル: EventTests.cs プロジェクト: plcode7/Itc4net
        public void ImplicitConversionOperatorShouldReturnLeafWhenInteger()
        {
            Event e1 = new Event.Leaf(4);
            Event e2 = 4;

            e1.Equals(e2).Should().BeTrue();
        }
コード例 #2
0
ファイル: EventTests.cs プロジェクト: plcode7/Itc4net
        public void MaxShouldReturnNWhenLeafN()
        {
            // Arrange
            Event e = new Event.Leaf(3);

            // Act & Assert
            e.Max().Should().Be(3);
        }
コード例 #3
0
ファイル: EventTests.cs プロジェクト: plcode7/Itc4net
        public void LeqShouldReturnFalseWhenNodeN1PlusR1IsGreaterThanLeafLeafN2()
        {
            // Arrange
            Event e1 = new Event.Node(2, 0, 2);
            Event e2 = new Event.Leaf(3);

            // Act & Assert
            e1.Leq(e2).Should().BeFalse();
        }
コード例 #4
0
ファイル: EventTests.cs プロジェクト: plcode7/Itc4net
        public void LeqShouldReturnTrueWhenNodeN1PlusR1IsLessThanOrEqualToLeafN2()
        {
            // Arrange
            Event e1 = new Event.Node(2, 0, 1);
            Event e2 = new Event.Leaf(3);

            // Act & Assert
            e1.Leq(e2).Should().BeTrue();
        }
コード例 #5
0
ファイル: EventTests.cs プロジェクト: plcode7/Itc4net
        public void LeqShouldReturnFalseWhenN1IsGreaterThanN2()
        {
            // Arrange
            Event e1 = new Event.Leaf(2);
            Event e2 = new Event.Leaf(1);

            // Act & Assert
            e1.Leq(e2).Should().BeFalse();
        }
コード例 #6
0
ファイル: EventTests.cs プロジェクト: plcode7/Itc4net
        public void LeqShouldReturnTrueWhenN1EqualsN2()
        {
            // Arrange
            Event e1 = new Event.Leaf(1);
            Event e2 = new Event.Leaf(1);

            // Act & Assert
            e1.Leq(e2).Should().BeTrue();
        }
コード例 #7
0
ファイル: EventTests.cs プロジェクト: plcode7/Itc4net
        public void EqualsShouldReturnFalseWhenComparingLeafsWithDifferentValues()
        {
            // Arrange
            Event e1 = new Event.Leaf(0);
            Event e2 = new Event.Leaf(1);

            // Act & Assert
            e1.Equals(e2).Should().BeFalse();
        }
コード例 #8
0
ファイル: EventTests.cs プロジェクト: plcode7/Itc4net
        public void EqualsShouldReturnTrueWhenComparingLeafsWithSameValues()
        {
            // Arrange
            Event e1 = new Event.Leaf(0);
            Event e2 = new Event.Leaf(0);

            // Act & Assert
            e1.Equals(e2).Should().BeTrue();
        }
コード例 #9
0
ファイル: EventTests.cs プロジェクト: plcode7/Itc4net
        public void NormalizeShouldReturnNWhenLeafIsN()
        {
            // Arrange
            Event e = new Event.Leaf(2);

            // Act
            Event result = e.Normalize();

            // Assert
            result.Should().Be(new Event.Leaf(2));
        }
コード例 #10
0
ファイル: EventTests.cs プロジェクト: plcode7/Itc4net
        public void JoinShouldReturnDefinedValueWhenNodeN1AndLeafN2()
        {
            // Arrange
            Event e1 = new Event.Node(2, 0, 1);
            Event e2 = new Event.Leaf(1);

            // Act
            Event result = e1.Join(e2);

            // Assert
            result.Should().Be(new Event.Node(2, 0, 1));
        }
コード例 #11
0
ファイル: EventTests.cs プロジェクト: plcode7/Itc4net
        public void JoinShouldReturnMaxNWhenBothLeafs()
        {
            // Arrange
            Event e1 = new Event.Leaf(1);
            Event e2 = new Event.Leaf(2);

            // Act
            Event result = e1.Join(e2);

            // Assert
            result.Should().Be(new Event.Leaf(2));
        }
コード例 #12
0
ファイル: EventTests.cs プロジェクト: plcode7/Itc4net
        public void GetHashCodeShouldNotMatchWhenLeafsHaveDifferentValues()
        {
            // Arrange
            Event e1 = new Event.Leaf(0);
            Event e2 = new Event.Leaf(4);

            // Act
            int hash1 = e1.GetHashCode();
            int hash2 = e2.GetHashCode();

            e1.Equals(e2).Should().BeFalse();
        }
コード例 #13
0
ファイル: EventTests.cs プロジェクト: plcode7/Itc4net
        public void GetHashCodeShouldMatchWhenLeafsHaveSameValues()
        {
            // Arrange
            Event e1 = new Event.Leaf(0);
            Event e2 = new Event.Leaf(0);

            // Act
            int hash1 = e1.GetHashCode();
            int hash2 = e2.GetHashCode();

            e1.Equals(e2).Should().BeTrue();
        }
コード例 #14
0
ファイル: EventTests.cs プロジェクト: plcode7/Itc4net
        public void SinkShouldReturnDefinedValueForLeaf()
        {
            // Arrange
            int   n = 2;
            int   m = 1;
            Event e = new Event.Leaf(n);

            // Act
            Event result = e.Sink(m);

            // Assert
            result.Should().Be(new Event.Leaf(n - m));
        }
コード例 #15
0
ファイル: EventTests.cs プロジェクト: plcode7/Itc4net
        public void MatchShouldInvokeLeafActionWhenEventRepresentsLeaf()
        {
            // Arrange
            Event e = new Event.Leaf(0);

            Action <int> leafAction = Substitute.For <Action <int> >();
            Action <int, Event, Event> nodeAction = Substitute.For <Action <int, Event, Event> >();

            // Act
            e.Match(leafAction, nodeAction);

            // Assert
            leafAction.Received().Invoke(0);
            nodeAction.DidNotReceiveWithAnyArgs();
        }
コード例 #16
0
ファイル: EventTests.cs プロジェクト: plcode7/Itc4net
        public void MatchShouldInvokeLeafFuncWhenNodeRepresentsLeaf()
        {
            // Arrange
            Event e = new Event.Leaf(0);

            Func <int, object> leafFn = Substitute.For <Func <int, object> >();
            Func <int, Event, Event, object> nodeFn = Substitute.For <Func <int, Event, Event, object> >();

            // Act
            e.Match(leafFn, nodeFn);

            // Assert
            leafFn.Received().Invoke(0);
            nodeFn.DidNotReceiveWithAnyArgs();
        }
コード例 #17
0
ファイル: Decoder.cs プロジェクト: plcode7/Itc4net
        Event DecodeEvent()
        {
            Event e = null;

            byte prefix1 = Scan(1);

            switch (prefix1)
            {
            case 0:     // node
                e = DecodeEventNode();
                break;

            case 1:     // leaf
                int n = DecodeN(2);
                e = new Event.Leaf(n);
                break;

            default:
                ThrowUnexpected(prefix1);
                break;
            }

            return(e);
        }