public void LocalTextRegistry_Add_OverridesExisting()
        {
            var registry = new LocalTextRegistry();

            registry.Add("es", "key", "oldTranslation");

            Assert.Equal("oldTranslation", registry.TryGet("es", "key"));

            registry.Add("es", "key", "newTranslation");

            Assert.Equal("newTranslation", registry.TryGet("es", "key"));
        }
Пример #2
0
        public void LocalTextRegistry_AddPending_DoesntOverrideApprovedText()
        {
            using (new MunqContext())
            {
                bool pending = true;

                var ctx = A.Fake<ILocalTextContext>();
                A.CallTo(() => ctx.IsApprovalMode).ReturnsLazily(() => pending);

                Dependency.Resolve<IDependencyRegistrar>()
                    .RegisterInstance<ILocalTextContext>(ctx);

                var registry = new LocalTextRegistry();
                registry.Add("es", "key", "approvedTranslation");
                Assert.Equal("approvedTranslation", registry.TryGet("es", "key"));

                registry.AddPending("es", "key", "pendingTranslation1");
                Assert.Equal("pendingTranslation1", registry.TryGet("es", "key"));

                pending = false;

                Assert.Equal("approvedTranslation", registry.TryGet("es", "key"));

                pending = true;

                registry.AddPending("es", "key", "pendingTranslation2");
                Assert.Equal("pendingTranslation2", registry.TryGet("es", "key"));

                pending = false;

                Assert.Equal("approvedTranslation", registry.TryGet("es", "key"));
            }
        }
        public void LocalTextRegistry_AddPending_DoesntOverrideApprovedText()
        {
            using (new MunqContext())
            {
                bool pending = true;

                var ctx = A.Fake <ILocalTextContext>();
                A.CallTo(() => ctx.IsApprovalMode).ReturnsLazily(() => pending);

                Dependency.Resolve <IDependencyRegistrar>()
                .RegisterInstance <ILocalTextContext>(ctx);

                var registry = new LocalTextRegistry();
                registry.Add("es", "key", "approvedTranslation");
                Assert.Equal("approvedTranslation", registry.TryGet("es", "key"));

                registry.AddPending("es", "key", "pendingTranslation1");
                Assert.Equal("pendingTranslation1", registry.TryGet("es", "key"));

                pending = false;

                Assert.Equal("approvedTranslation", registry.TryGet("es", "key"));

                pending = true;

                registry.AddPending("es", "key", "pendingTranslation2");
                Assert.Equal("pendingTranslation2", registry.TryGet("es", "key"));

                pending = false;

                Assert.Equal("approvedTranslation", registry.TryGet("es", "key"));
            }
        }
        public void LocalTextRegistry_Add_DoesntTrimAny()
        {
            var registry = new LocalTextRegistry();

            registry.Add("  es  ", " key ", " translation ");

            var actual = registry.TryGet("  es  ", " key ");

            Assert.Equal(" translation ", actual);
        }
Пример #5
0
        public void LocalTextRegistry_AddPending_DoesntTrimAny()
        {
            using (new MunqContext())
            {
                bool pending = true;

                var ctx = A.Fake<ILocalTextContext>();
                A.CallTo(() => ctx.IsApprovalMode).ReturnsLazily(() => pending);

                Dependency.Resolve<IDependencyRegistrar>()
                    .RegisterInstance<ILocalTextContext>(ctx);

                var registry = new LocalTextRegistry();
                registry.Add("  es  ", " key ", " translation ");

                var actual = registry.TryGet("  es  ", " key ");
                Assert.Equal(" translation ", actual);
            }
        }
        public void LocalTextRegistry_AddPending_DoesntTrimAny()
        {
            using (new MunqContext())
            {
                bool pending = true;

                var ctx = A.Fake <ILocalTextContext>();
                A.CallTo(() => ctx.IsApprovalMode).ReturnsLazily(() => pending);

                Dependency.Resolve <IDependencyRegistrar>()
                .RegisterInstance <ILocalTextContext>(ctx);

                var registry = new LocalTextRegistry();
                registry.Add("  es  ", " key ", " translation ");

                var actual = registry.TryGet("  es  ", " key ");
                Assert.Equal(" translation ", actual);
            }
        }
Пример #7
0
        public void LocalTextRegistry_Add_WorksProperly()
        {
            var registry = new LocalTextRegistry();
            registry.Add("es", "key", "translation");

            var actual = registry.TryGet("es", "key");
            Assert.Equal("translation", actual);
        }
Пример #8
0
        public void LocalTextRegistry_Add_OverridesExisting()
        {
            var registry = new LocalTextRegistry();
            registry.Add("es", "key", "oldTranslation");

            Assert.Equal("oldTranslation", registry.TryGet("es", "key"));

            registry.Add("es", "key", "newTranslation");

            Assert.Equal("newTranslation", registry.TryGet("es", "key"));
        }