public void ResourceFileMultipleAddsCaseDifference() { Project testProject = (Project)(extensibility.Solution.Projects.Item(1)); IExtractResourceAction action = new GenericCSharpExtractResourceAction(); ResourceFileCollection collection = new ResourceFileCollection(testProject, new FilterMethod(action.IsValidResourceFile)); ResourceFile testFile = collection[0]; testFile.AddResource("Test2", "Test3", "Comment Test"); testFile.AddResource("test2", "TestTest", "Comment"); }
public void ResourceFileMultipleAddsSameName() { Assert.Throws <ArgumentException>(() => { Project testProject = (Project)(extensibility.Solution.Projects.Item(1)); IExtractResourceAction action = new GenericCSharpExtractResourceAction(); ResourceFileCollection collection = new ResourceFileCollection(testProject, new FilterMethod(action.IsValidResourceFile)); ResourceFile testFile = collection[0]; testFile.AddResource("Test2", "Test3", "Comment Test"); testFile.AddResource("Test2", "TestTest", "Comment"); }); }
public void ResourceFileReadAfterRefreshWithoutSave() { Project testProject = (Project)(extensibility.Solution.Projects.Item(1)); IExtractResourceAction action = new GenericCSharpExtractResourceAction(); ResourceFileCollection collection = new ResourceFileCollection(testProject, new FilterMethod(action.IsValidResourceFile)); ResourceFile testFile = collection[0]; Assert.AreEqual(2, testFile.Resources.Count, Messages.ResourceCountInvalid); Assert.AreEqual("Test", testFile.GetValue("TestResource"), Messages.ResourceValueInvalid); testFile.AddResource("Test2", "Test3", "Comment Test"); testFile.Refresh(); Assert.AreEqual(2, testFile.Resources.Count, Messages.ResourceCountInvalid); Assert.AreEqual("Test", testFile.GetValue("TestResource"), Messages.ResourceValueInvalid); }
public void ResourceFileReadAfterSave() { Project testProject = (Project)(extensibility.Solution.Projects.Item(1)); IExtractResourceAction action = new GenericCSharpExtractResourceAction(); ResourceFileCollection collection = new ResourceFileCollection(testProject, new FilterMethod(action.IsValidResourceFile)); ResourceFile testFile = collection[1]; FileAttributes attributes = File.GetAttributes(testFile.FileName); if (File.Exists(testFile.FileName + ".bak")) { File.SetAttributes(testFile.FileName + ".bak", attributes & ~FileAttributes.ReadOnly); File.Delete(testFile.FileName + ".bak"); } File.Copy(testFile.FileName, testFile.FileName + ".bak"); File.SetAttributes(testFile.FileName, attributes & ~FileAttributes.ReadOnly); File.SetAttributes(testFile.FileName + ".bak", attributes & ~FileAttributes.ReadOnly); try { Assert.AreEqual(1, testFile.Resources.Count, Messages.ResourceCountInvalid); Assert.AreEqual("Test", testFile.GetValue("TestString"), Messages.ResourceValueInvalid); testFile.AddResource("Test2", "Test3", "Comment Test"); testFile.SaveFile(); testFile.Refresh(); Assert.AreEqual(2, testFile.Resources.Count, Messages.ResourceCountInvalid); Assert.AreEqual("Test", testFile.GetValue("TestString"), Messages.ResourceValueInvalid); Assert.AreEqual("Comment Test", testFile.Resources["TestString"].Comment, Messages.ResourceCommentInvalid); Assert.AreEqual("Test3", testFile.GetValue("Test2"), Messages.ResourceValueInvalid); Assert.AreEqual("Comment Test", testFile.Resources["Test2"].Comment, Messages.ResourceCommentInvalid); } finally { File.Delete(testFile.FileName); File.Move(testFile.FileName + ".bak", testFile.FileName); File.SetAttributes(testFile.FileName, attributes); } }