コード例 #1
0
        public void GetHashCodeTest()
        {
            var rnd = new Random();
            Mock <IDictionary <string, string> > mock;
            int          expect = 0;
            int          actual = 0;
            ParserResult sut;

            // Testing Hashcode
            expect = rnd.Next();
            mock   = new Mock <IDictionary <string, string> >();
            mock.Setup(dict => dict.GetHashCode()).Returns(expect);
            sut    = new ParserResult(mock.Object);
            actual = sut.GetHashCode();
            Assert.Equal(expect, actual);
            actual = sut.GetHashCode();
            Assert.Equal(expect, actual);
            mock.Verify(dict => dict.GetHashCode(), Times.Exactly(2));
        }
コード例 #2
0
        public void GetHashCodeTest()
        {
            ParserResult sut;

            // Testing Hashcode
            var mock   = new Dictionary <string, string>();
            int expect = 0;
            int actual = 0;

            sut = new ParserResult(mock);

            expect = mock.GetHashCode();
            actual = sut.GetHashCode();
            Assert.Equal(expect, actual);

            mock.Add("akey", "testing value");
            expect = mock.GetHashCode();
            actual = sut.GetHashCode();
            Assert.Equal(expect, actual);
        }