public void ObjectExtenderContainerConverterConvertFromTypeCompliantWithXmlSerializer()
		{
			MockServiceProvider mockServiceProvider = new MockServiceProvider();
			Type[] types = { typeof(TestSerializableObject) };
			MockServiceProviderService mockService = new MockServiceProviderService();
			mockService.ObjectExtenderTypes.Add(types[0]);
			mockServiceProvider.AddService(typeof(IExtensionProviderService), mockService);

			ObjectExtenderContainerConverter converter = new ObjectExtenderContainerConverter(mockServiceProvider);

			TestSerializableObject testObject1 = new TestSerializableObject();
			testObject1.ValueOne = "TestDataOne";
			testObject1.ValueTwo = 33;
			string stringRepresentation;
			ObjectExtenderContainer container1 = new ObjectExtenderContainer();
			container1.ObjectExtenders.Add(testObject1);

			stringRepresentation = GenericSerializer.Serialize<ObjectExtenderContainer>(container1, types);

			ObjectExtenderContainer container2 = converter.ConvertFrom(stringRepresentation) as ObjectExtenderContainer;

			Assert.IsNotNull(container2, "container is null");
			Assert.IsNotNull(container2.ObjectExtenders, "ObjectExtenders is null");
			Assert.AreEqual(1, container2.ObjectExtenders.Count, "container.ObjectExtenders.Count != 1");

			TestSerializableObject testObject2 = container2.ObjectExtenders[0] as TestSerializableObject;
			Assert.AreEqual(testObject1.ValueOne, testObject2.ValueOne, "Not equal");
			Assert.AreEqual(testObject1.ValueTwo, testObject2.ValueTwo, "Not equal");
		}
		public void ObjectExtenderContainerConverterCanConvertFromString()
		{
			MockServiceProvider mockServiceProvider = new MockServiceProvider();
			MockServiceProviderService mockService = new MockServiceProviderService();

			mockServiceProvider.AddService(typeof(IExtensionProviderService), mockService);

			ObjectExtenderContainerConverter converter = new ObjectExtenderContainerConverter(mockServiceProvider);

			Assert.IsTrue(converter.CanConvertFrom(typeof(string)), "Cannot convert from a string");
		}
コード例 #3
0
		public void EditValueWithNoFormsServiceThrows()
		{
			MockVSHierarchy root = new MockVSHierarchy();
			MockVsSolution solution = new MockVsSolution(root);
			MockServiceProvider serviceProvider = new MockServiceProvider();
			serviceProvider.AddService(typeof(IVsSolution), solution);
			MockTypeDescriptorContext context = new MockTypeDescriptorContext(serviceProvider);
			string value = "Project1.txt";
			MockVSHierarchy project = new MockVSHierarchy(value);
			root.AddProject(project);
			SolutionPickerEditor target = new SolutionPickerEditor();
			target.EditValue(serviceProvider, null);
		}
コード例 #4
0
		public void ExtensionProviderContainerConverterConvertToExtensionProvider()
		{
			MockExtensionProvider provider = new MockExtensionProvider();
			MockServiceProvider mockServiceProvider = new MockServiceProvider();
			MockServiceProviderService mockService = new MockServiceProviderService();

			mockServiceProvider.AddService(typeof(IExtensionProviderService), mockService);

			ExtensionProviderConverter converter = new ExtensionProviderConverter(mockServiceProvider);

			MockExtensionProvider provider1 = converter.ConvertFrom(provider.ToString()) as MockExtensionProvider;

			Assert.AreEqual(provider.Id, provider1.Id, "Not Equal");
			Assert.AreEqual(provider.Description, provider1.Description, "Not Equal");
			Assert.AreEqual(provider.Name, provider1.Name, "Not Equal");
		}
コード例 #5
0
		public void TestValidate()
		{
			MockServiceProvider serviceProvider = new MockServiceProvider();
			MockVSHierarchy root = new MockVSHierarchy();
			MockVsSolution solution = new MockVsSolution(root);
			MockVSHierarchy project = new MockVSHierarchy("Project1.project");
			root.AddProject(project);
			serviceProvider.AddService(typeof(SVsSolution), solution);
			CodeGenerationService target = new CodeGenerationService(serviceProvider);
			MyArtifactLink validLink = new MyArtifactLink(project.GUID, "item1.cs");

			Assert.IsTrue(target.IsValid(validLink));
			MyArtifactLink invalidLink1 = new MyArtifactLink(Guid.NewGuid(), "item2.cs");
			Assert.IsFalse(target.IsValid(invalidLink1));
			MyArtifactLink invalidLink2 = new MyArtifactLink(project.GUID, "it:em3.cs");
			Assert.IsFalse(target.IsValid(invalidLink2));
			MyArtifactLink invalidLink3 = new MyArtifactLink(Guid.NewGuid(), "<item3.cs>");
			Assert.IsFalse(target.IsValid(invalidLink3));
		}
コード例 #6
0
		private static CodeGenerationService CreateCodeGenerator(string itemPath, out MockVsRDT rdt)
		{
			string fullItemPath = Path.Combine(Directory.GetCurrentDirectory(), itemPath);
			string fullProjectPath = Path.Combine(Directory.GetCurrentDirectory(), "Project.project");
			MockServiceProvider serviceProvider = new MockServiceProvider();
			MockVSHierarchy vsHierarchy = new MockVSHierarchy(fullProjectPath);
			MockVsSolution vsSolution = new MockVsSolution(vsHierarchy);
			rdt = new MockVsRDT(fullItemPath, vsHierarchy, 0);
			MockVsTextManager textManager = new MockVsTextManager();
            MockVsUIShellOpenDocument shellOpenDocument = new MockVsUIShellOpenDocument();
			serviceProvider.AddService(typeof(SVsSolution), vsSolution);
			serviceProvider.AddService(typeof(IVsRunningDocumentTable), rdt);
			serviceProvider.AddService(typeof(VsTextManagerClass), textManager);
            serviceProvider.AddService(typeof(SVsUIShellOpenDocument), shellOpenDocument);
			return new TestableCodeGenerationService(serviceProvider);
		}
コード例 #7
0
		public void TestValidateEmptyRename()
		{
			MockServiceProvider serviceProvider = new MockServiceProvider();
			MockVSHierarchy root = new MockVSHierarchy();
			MockVsSolution solution = new MockVsSolution(root);
			MockVSHierarchy project = new MockVSHierarchy("Project1.project");
			root.AddProject(project);
			serviceProvider.AddService(typeof(SVsSolution), solution);
			TestableCodeGenerationService target = new TestableCodeGenerationService(serviceProvider);
			string oldName = "item1";
			string newName = "";
			MyArtifactLink validLink = new MyArtifactLink(project.GUID, oldName + ".cs");
			HierarchyNode node = target.ValidateRename(validLink, newName, oldName);

			Assert.IsNull(node);
			project.AddChild(oldName + ".cs");
			node = target.ValidateRename(validLink, oldName, oldName);
			Assert.IsNull(node);
			Assert.AreEqual<int>(0, target.LogEntries.Count);
			node = target.ValidateRename(validLink, newName, oldName);
			Assert.IsNotNull(node);
			Assert.AreEqual<int>(1, target.LogEntries.Count);
		}
コード例 #8
0
		public void TestArtifactIsGenerated()
		{
			MockServiceProvider serviceProvider = new MockServiceProvider();
			MockVSHierarchy root = new MockVSHierarchy();
			MockVsSolution solution = new MockVsSolution(root);
			MockVSHierarchy project = new MockVSHierarchy("Project1.project");
			root.AddProject(project);
			serviceProvider.AddService(typeof(SVsSolution), solution);
			CodeGenerationService target = new CodeGenerationService(serviceProvider);
			MyArtifactLink validLink = new MyArtifactLink(project.GUID, "item1.cs");

			Assert.IsFalse(target.IsArtifactAlreadyGenerated(validLink));
			project.AddChild("item1.cs");
			Assert.IsTrue(target.IsArtifactAlreadyGenerated(validLink));
		}
		public void ObjectExtenderContainerConverterConvertToTypeCompliantWithXmlSerializer()
		{
			MockServiceProvider mockServiceProvider = new MockServiceProvider();
			MockServiceProviderService mockService = new MockServiceProviderService();

			mockServiceProvider.AddService(typeof(IExtensionProviderService), mockService);

			ObjectExtenderContainerConverter converter = new ObjectExtenderContainerConverter(mockServiceProvider);

			TestSerializableObject testObject1 = new TestSerializableObject();
			testObject1.ValueOne = "TestDataOne";
			testObject1.ValueTwo = 33;
			string stringRepresentation;
			Type[] types = { typeof(TestSerializableObject) };
			ObjectExtenderContainer container1 = new ObjectExtenderContainer();
			container1.ObjectExtenders.Add(testObject1);

			stringRepresentation = GenericSerializer.Serialize<ObjectExtenderContainer>(container1, types);

			string stringRepresentation2 = converter.ConvertTo(stringRepresentation, typeof(string)) as string;

			Assert.AreEqual(stringRepresentation, stringRepresentation2, "Not equal");
		}