Ejemplo n.º 1
0
        public void equals_is_namespace_aware()
        {
            var token1 = StringToken.FromKeyString("something");
            var token2 = StringToken.FromKeyString("something");
            var token3 = StringToken.FromKeyString("else");

            // FakeToken is namespaced
            var token4 = new FakeToken("something");
            var token5 = new FakeToken("something");
            var token6 = new FakeToken("else");

            token1.ShouldBe(token2);
            token2.ShouldBe(token1);
            token3.ShouldNotBe(token1);
            token1.ShouldNotBe(token3);

            token4.ShouldBe(token5);
            token5.ShouldBe(token4);
            token6.ShouldNotBe(token4);
            token4.ShouldNotBe(token6);

            // Namespace matters here
            token1.ShouldNotBe(token4);
            token3.ShouldNotBe(token6);
        }
Ejemplo n.º 2
0
        public void GetHashCode_depends_on_the_localization_key()
        {
            var token1 = StringToken.FromKeyString("something");
            var token2 = StringToken.FromKeyString("something");
            var token3 = StringToken.FromKeyString("else");

            // FakeToken is namespaced
            var token4 = new FakeToken("something");
            var token5 = new FakeToken("something");
            var token6 = new FakeToken("else");

            token1.GetHashCode().ShouldBe(token2.GetHashCode());
            token2.GetHashCode().ShouldBe(token1.GetHashCode());
            token3.GetHashCode().ShouldNotBe(token1.GetHashCode());
            token1.GetHashCode().ShouldNotBe(token3.GetHashCode());

            token4.GetHashCode().ShouldBe(token5.GetHashCode());
            token5.GetHashCode().ShouldBe(token4.GetHashCode());
            token6.GetHashCode().ShouldNotBe(token4.GetHashCode());
            token4.GetHashCode().ShouldNotBe(token6.GetHashCode());

            // Namespace matters here
            token1.GetHashCode().ShouldNotBe(token4.GetHashCode());
            token3.GetHashCode().ShouldNotBe(token6.GetHashCode());
        }