public void CoupleResources_SameRootKey_TwoHidden_RootIsNotHidden(string[] resourceKeys, bool[] visibilityFlags, bool isLegacyMode) { var sut = new ResourceTreeBuilder(); var model = new List <ResourceListItem>(); for (var i = 0; i < resourceKeys.Length; i++) { model.Add(new ResourceListItem(resourceKeys[i], new List <ResourceItem>(new[] { new ResourceItem(resourceKeys[i], "another translation", new CultureInfo("en")) }), true, visibilityFlags[i], true)); } var result = sut.BuildTree(model, isLegacyMode); var shareRootKey = result.Single(r => r.KeyFragment == "MyNamespace"); var shareParentKey = result.Single(r => r.KeyFragment == "MyProject"); Assert.False(shareRootKey.IsHidden); Assert.False(shareParentKey.IsHidden); }
public void SingleResource_SplitIntoKeyFragments_AllRegistered(string resourceKey, bool isLegacyModeEnabled) { var sut = new ResourceTreeBuilder(); var model = new List <ResourceListItem> { new ResourceListItem(resourceKey, new List <ResourceItem>(new[] { new ResourceItem(resourceKey, "sample translation", new CultureInfo("en")) }), true, false, true) }; var result = sut.BuildTree(model, isLegacyModeEnabled); Assert.NotNull(result); Assert.Equal(3, result.Count); Assert.False(result.First().IsLeaf); Assert.False(result.Skip(1).First().IsLeaf); Assert.True(result.Skip(2).First().IsLeaf); }
public void TwoResources_UnderSingleRootKey_VerifyOrder() { var sut = new ResourceTreeSorter(); var builder = new ResourceTreeBuilder(); var model = new List <ResourceListItem> { new ResourceListItem("MyNamespace.MyProject.MyResource", new List <ResourceItem>(new[] { new ResourceItem("MyNamespace.MyProject.MyResource", "sample translation", new CultureInfo("en")) }), true, false), new ResourceListItem("MyNamespace.MyProject.AnotherResource", new List <ResourceItem>(new[] { new ResourceItem("MyNamespace.MyProject.AnotherResource", "another translation", new CultureInfo("en")) }), true, false) }; var result = sut.Sort(builder.BuildTree(model)).ToList(); Assert.NotNull(result); Assert.Equal(4, result.Count); Assert.Equal("MyNamespace", result.First().KeyFragment); Assert.Equal("MyResource", result.Skip(3).First().KeyFragment); }
public void TwoResources_SimilarParent_DifferentRootKeys_OneHidden_ParentIsHidden( string[] resourceKeys, bool[] visibilityFlags, bool isLecagyMode, string parentResourcePath1, string parentResourcePath2) { var sut = new ResourceTreeBuilder(); var model = new List <ResourceListItem>(); for (var i = 0; i < resourceKeys.Length; i++) { model.Add(new ResourceListItem(resourceKeys[i], new List <ResourceItem>(new[] { new ResourceItem(resourceKeys[i], "another translation", new CultureInfo("en")) }), true, visibilityFlags[i], true)); } var result = sut.BuildTree(model, isLecagyMode); var similarParentKey = result.Single(r => r.Path == parentResourcePath1); var anotherSimilarParentKey = result.Single(r => r.Path == parentResourcePath2); Assert.True(similarParentKey.IsHidden); Assert.False(anotherSimilarParentKey.IsHidden); }
public void TwoResources_SameRootKey_OneHidden_RootIsNotHidden() { var sut = new ResourceTreeBuilder(); var model = new List <ResourceListItem> { new ResourceListItem("MyNamespace.MyProject.AnotherResource", new List <ResourceItem>(new[] { new ResourceItem("MyNamespace.MyProject.AnotherResource", "another translation", new CultureInfo("en")) }), true, true), new ResourceListItem("MyNamespace.MyProject.MyResource", new List <ResourceItem>(new[] { new ResourceItem("MyNamespace.MyProject.MyResource", "sample translation", new CultureInfo("en")) }), true, false) }; var result = sut.BuildTree(model).ToList(); var shareRootKey = result.Single(r => r.KeyFragment == "MyNamespace"); var shareParentKey = result.Single(r => r.KeyFragment == "MyProject"); Assert.False(shareRootKey.IsHidden); Assert.False(shareParentKey.IsHidden); }
public void TwoResources_UnderSingleRootKey_BothRegistered() { var sut = new ResourceTreeBuilder(); var model = new List <ResourceListItem> { new ResourceListItem("MyNamespace.MyProject.MyResource", new List <ResourceItem>(new[] { new ResourceItem("MyNamespace.MyProject.MyResource", "sample translation", new CultureInfo("en")) }), true, false), new ResourceListItem("MyNamespace.MyProject.AnotherResource", new List <ResourceItem>(new[] { new ResourceItem("MyNamespace.MyProject.AnotherResource", "another translation", new CultureInfo("en")) }), true, false) }; var result = sut.BuildTree(model).ToList(); Assert.NotNull(result); Assert.Equal(4, result.Count); }
public void TwoResources_SimilarParent_DifferentRootKeys_OneHidden_ParentIsHidden() { var sut = new ResourceTreeBuilder(); var model = new List <ResourceListItem> { new ResourceListItem("MyNamespace.MyProject.AnotherResource", new List <ResourceItem>(new[] { new ResourceItem("MyNamespace.MyProject.AnotherResource", "another translation", new CultureInfo("en")) }), true, true), new ResourceListItem("AnotherNamespace.MyProject.MyResource", new List <ResourceItem>(new[] { new ResourceItem("AnotherNamespace.MyProject.MyResource", "sample translation", new CultureInfo("en")) }), true, false) }; var result = sut.BuildTree(model).ToList(); var similarParentKey = result.Single(r => r.Path == "MyNamespace.MyProject"); var anotherSimilarParentKey = result.Single(r => r.Path == "AnotherNamespace.MyProject"); Assert.True(similarParentKey.IsHidden); Assert.False(anotherSimilarParentKey.IsHidden); }
public void MultipleResources_HavingSimilarKeyFragment_RegisteredUnderCorrectParent_VerifyOrder() { var sut = new ResourceTreeSorter(); var builder = new ResourceTreeBuilder(); var model = new List <ResourceListItem> { new ResourceListItem("MyNamespace.MyProject.MyResource", new List <ResourceItem>(new[] { new ResourceItem("MyNamespace.MyProject.MyResource", "sample translation", new CultureInfo("en")) }), true, false, true), new ResourceListItem("MyNamespace.MyProject.AnotherResource", new List <ResourceItem>(new[] { new ResourceItem("MyNamespace.MyProject.AnotherResource", "another translation", new CultureInfo("en")) }), true, false, true), new ResourceListItem("OtherNamespace.MyProject.OtherResource", new List <ResourceItem>(new[] { new ResourceItem("OtherNamespace.MyProject.OtherResource", "other translation", new CultureInfo("en")) }), true, false, true) }; var result = sut.Sort(builder.BuildTree(model)).ToList(); Assert.NotNull(result); Assert.Equal(7, result.Count); Assert.Equal(5, result.Single(r => r.KeyFragment == "OtherResource").ParentId); }
public void MixedResources_AllRegistered(string[] resourceKeys, bool isLegacyMode) { var sut = new ResourceTreeBuilder(); var model = new List <ResourceListItem>(); foreach (var resourceKey in resourceKeys) { model.Add(new ResourceListItem(resourceKey, new List <ResourceItem>(new[] { new ResourceItem(resourceKey, "sample translation", new CultureInfo("en")) }), true, false)); } var result = sut.BuildTree(model, isLegacyMode); Assert.NotNull(result); Assert.Equal(5, result.Count); }
public void MultipleResources_HavingSimilarKeyFragment_RegisteredUnderCorrectParent(IEnumerable <string> resourceKeys, bool isLegacyMode) { var sut = new ResourceTreeBuilder(); var model = new List <ResourceListItem>(); foreach (var resourceKey in resourceKeys) { model.Add(new ResourceListItem(resourceKey, new List <ResourceItem>(new[] { new ResourceItem(resourceKey, "sample translation", new CultureInfo("en")) }), true, false)); } var result = sut.BuildTree(model, isLegacyMode); Assert.NotNull(result); Assert.Equal(7, result.Count); }
public void SingleResource_SplitIntoKeyFragments_AllRegistered() { var sut = new ResourceTreeBuilder(); var model = new List <ResourceListItem> { new ResourceListItem("MyNamespace.MyProject.MyResource", new List <ResourceItem>(new[] { new ResourceItem("MyNamespace.MyProject.MyResource", "sample translation", new CultureInfo("en")) }), true, false) }; var result = sut.BuildTree(model).ToList(); Assert.NotNull(result); Assert.Equal(3, result.Count); Assert.False(result.First().IsLeaf); Assert.False(result.Skip(1).First().IsLeaf); Assert.True(result.Skip(2).First().IsLeaf); }