public void NestedLocalTextRegistration_Initialize_ThrowsArgumentNull_IfAssembliesIsNull() { using (new MunqContext()) { var exception = Assert.Throws <ArgumentNullException>(() => { NestedLocalTextRegistration.Initialize(null); }); } }
public void NestedLocalTextRegistration_Initialize_ThrowsKeyNotFound_IfNoLocalTextRegistry() { using (new MunqContext()) { var exception = Assert.Throws <KeyNotFoundException>(() => { NestedLocalTextRegistration.Initialize(new[] { this.GetType().Assembly }); }); Assert.Contains(typeof(ILocalTextRegistry).Name, exception.Message); } }
public void NestedLocalTextRegistration_Initialize_OnlyRunsOnSpecifiedAssemblies() { using (new MunqContext()) { var registry = A.Fake <ILocalTextRegistry>(); Dependency.Resolve <IDependencyRegistrar>() .RegisterInstance(registry); NestedLocalTextRegistration.Initialize(new[] { typeof(System.Object).Assembly }); A.CallTo(() => registry.Add(A <string> ._, A <string> ._, A <string> ._)) .MustNotHaveHappened(); } }
public void NestedLocalTextRegistration_Initialize_UsesRegisteredLocalTextRegistry() { using (new MunqContext()) { var registry = A.Fake <ILocalTextRegistry>(); Dependency.Resolve <IDependencyRegistrar>() .RegisterInstance(registry); NestedLocalTextRegistration.Initialize(new[] { this.GetType().Assembly }); A.CallTo(() => registry.Add(A <string> ._, A <string> ._, A <string> ._)) .MustHaveHappened(); } }
public static void InitializeLocalTexts() { var registrar = Dependency.Resolve <IDependencyRegistrar>(); if (Dependency.TryResolve <ILocalTextRegistry>() == null) { registrar.RegisterInstance <ILocalTextRegistry>(new LocalTextRegistry()); } NestedLocalTextRegistration.Initialize(ExtensibilityHelper.SelfAssemblies); EnumLocalTextRegistration.Initialize(ExtensibilityHelper.SelfAssemblies); EntityLocalTexts.Initialize(); JsonLocalTextRegistration.AddFromFilesInFolder(HostingEnvironment.MapPath("~/Scripts/serenity/texts/")); JsonLocalTextRegistration.AddFromFilesInFolder(HostingEnvironment.MapPath("~/Scripts/site/texts/")); }
public void NestedLocalTextRegistration_Initialize_SkipsClassesWithoutNestedLocalTextsAttribute() { using (new MunqContext()) { var registry = A.Fake <ILocalTextRegistry>(); Dependency.Resolve <IDependencyRegistrar>() .RegisterInstance(registry); NestedLocalTextRegistration.Initialize(new[] { this.GetType().Assembly }); A.CallTo(() => registry.Add(LocalText.InvariantLanguageID, "N.N1", "5")) .MustNotHaveHappened(); A.CallTo(() => registry.Add(LocalText.InvariantLanguageID, "Y.Y1", "1")) .MustHaveHappened(Repeated.Exactly.Once); } }
public void NestedLocalTextRegistration_Initialize_RemovesLastUnderscoreFromClassName() { using (new MunqContext()) { var registry1 = A.Fake <ILocalTextRegistry>(); Dependency.Resolve <IDependencyRegistrar>() .RegisterInstance(registry1); NestedLocalTextRegistration.Initialize(new[] { this.GetType().Assembly }); A.CallTo(() => registry1.Add(LocalText.InvariantLanguageID, "Y4", "4")) .MustHaveHappened(Repeated.Exactly.Once); A.CallTo(() => registry1.Add(LocalText.InvariantLanguageID, "Y4.Y5", "5")) .MustHaveHappened(Repeated.Exactly.Once); } }
public void NestedLocalTextRegistration_Initialize_ReplacesLocalTextObjectsWithInitializedLocalTextObjects() { using (new MunqContext()) { var registry = A.Fake <ILocalTextRegistry>(); Dependency.Resolve <IDependencyRegistrar>() .RegisterInstance(registry); NestedLocalTextRegistration.Initialize(new[] { this.GetType().Assembly }); Assert.IsType <InitializedLocalText>(Texts.Y.Y1); Assert.IsType <InitializedLocalText>(Texts.Y.Y2); Assert.IsType <InitializedLocalText>(Texts.Y.YI.Y3); Assert.IsType <InitializedLocalText>(Texts.Y4); Assert.Equal("Y.Y1", Texts.Y.Y1.Key); Assert.Equal("1", ((InitializedLocalText)Texts.Y.Y1).InitialText); } }
public void NestedLocalTextRegistration_Initialize_CanBeCalledMoreThanOnce() { using (new MunqContext()) { var registry1 = A.Fake <ILocalTextRegistry>(); Dependency.Resolve <IDependencyRegistrar>() .RegisterInstance(registry1); NestedLocalTextRegistration.Initialize(new[] { this.GetType().Assembly }); A.CallTo(() => registry1.Add(LocalText.InvariantLanguageID, "Y.Y1", "1")) .MustHaveHappened(Repeated.Exactly.Once); A.CallTo(() => registry1.Add(LocalText.InvariantLanguageID, "Y.Y2", "2")) .MustHaveHappened(Repeated.Exactly.Once); A.CallTo(() => registry1.Add(LocalText.InvariantLanguageID, "Y.YI.Y3", "3")) .MustHaveHappened(Repeated.Exactly.Once); A.CallTo(() => registry1.Add(LocalText.InvariantLanguageID, "Y4", "4")) .MustHaveHappened(Repeated.Exactly.Once); var registry2 = A.Fake <ILocalTextRegistry>(); Dependency.Resolve <IDependencyRegistrar>() .RegisterInstance(registry2); NestedLocalTextRegistration.Initialize(new[] { this.GetType().Assembly }); A.CallTo(() => registry2.Add(LocalText.InvariantLanguageID, "Y.Y1", "1")) .MustHaveHappened(Repeated.Exactly.Once); A.CallTo(() => registry2.Add(LocalText.InvariantLanguageID, "Y.Y2", "2")) .MustHaveHappened(Repeated.Exactly.Once); A.CallTo(() => registry2.Add(LocalText.InvariantLanguageID, "Y.YI.Y3", "3")) .MustHaveHappened(Repeated.Exactly.Once); A.CallTo(() => registry2.Add(LocalText.InvariantLanguageID, "Y4", "4")) .MustHaveHappened(Repeated.Exactly.Once); } }
public void NestedLocalTextRegistration_Initialize_UsesLanguageAndPrefixIfSpecified() { using (new MunqContext()) { var registry = A.Fake <ILocalTextRegistry>(); Dependency.Resolve <IDependencyRegistrar>() .RegisterInstance(registry); NestedLocalTextRegistration.Initialize(new[] { this.GetType().Assembly }); A.CallTo(() => registry.Add("jp", "x.X.X1", "1")) .MustHaveHappened(Repeated.Exactly.Once); A.CallTo(() => registry.Add("jp", "x.X.X2", "2")) .MustHaveHappened(Repeated.Exactly.Once); A.CallTo(() => registry.Add("jp", "x.X.XI.X3", "3")) .MustHaveHappened(Repeated.Exactly.Once); A.CallTo(() => registry.Add("jp", "x.X4", "4")) .MustHaveHappened(Repeated.Exactly.Once); } }
public void NestedLocalTextRegistration_Initialize_UsesInvariantLanguageAndNoPrefixByDefault() { using (new MunqContext()) { var registry = A.Fake <ILocalTextRegistry>(); Dependency.Resolve <IDependencyRegistrar>() .RegisterInstance(registry); NestedLocalTextRegistration.Initialize(new[] { this.GetType().Assembly }); A.CallTo(() => registry.Add(LocalText.InvariantLanguageID, "Y.Y1", "1")) .MustHaveHappened(1, Times.Exactly); A.CallTo(() => registry.Add(LocalText.InvariantLanguageID, "Y.Y2", "2")) .MustHaveHappened(1, Times.Exactly); A.CallTo(() => registry.Add(LocalText.InvariantLanguageID, "Y.YI.Y3", "3")) .MustHaveHappened(1, Times.Exactly); A.CallTo(() => registry.Add(LocalText.InvariantLanguageID, "Y4", "4")) .MustHaveHappened(1, Times.Exactly); } }
public void NestedLocalTextRegistration_Initialize_UsesLanguageIfSpecified() { using (new MunqContext()) { var registry = A.Fake <ILocalTextRegistry>(); Dependency.Resolve <IDependencyRegistrar>() .RegisterInstance(registry); NestedLocalTextRegistration.Initialize(new[] { this.GetType().Assembly }); A.CallTo(() => registry.Add("es", "Z.Z1", "1")) .MustHaveHappened(1, Times.Exactly); A.CallTo(() => registry.Add("es", "Z.Z2", "2")) .MustHaveHappened(1, Times.Exactly); A.CallTo(() => registry.Add("es", "Z.ZI.Z3", "3")) .MustHaveHappened(1, Times.Exactly); A.CallTo(() => registry.Add("es", "Z4", "4")) .MustHaveHappened(1, Times.Exactly); } }