Example #1
0
        public void ProjectBindingOperation_Prepare_Cancellation()
        {
            // Setup
            this.ruleStore.RegisterRuleSetPath(Language.CSharp, @"c:\Solution\sln.ruleset");
            ProjectBindingOperation testSubject = this.CreateTestSubject();

            this.projectMock.SetCSProjectKind();
            PropertyMock prop = CreateProperty(this.projectMock, "config1", ProjectBindingOperation.DefaultProjectRuleSet);

            testSubject.Initialize();
            using (CancellationTokenSource src = new CancellationTokenSource())
            {
                CancellationToken token = src.Token;
                src.Cancel();

                // Act
                testSubject.Prepare(token);
            }

            // Verify
            string expectedFile = Path.Combine(Path.GetDirectoryName(this.projectMock.FilePath), Path.GetFileNameWithoutExtension(this.projectMock.FilePath) + ".ruleset");

            Assert.IsNull(testSubject.PropertyInformationMap[prop].NewRuleSetFilePath, "Not expecting the new rule set path to be set when canceled");
            Assert.AreEqual(ProjectBindingOperation.DefaultProjectRuleSet, prop.Value.ToString(), "Should not update the property value");
            Assert.IsFalse(this.projectMock.Files.ContainsKey(expectedFile), "Should not be added to the project");
        }
Example #2
0
        public void ProjectBindingOperation_Prepare_SameNonDefaultRuleSetsInProject()
        {
            // Setup
            this.ruleStore.RegisterRuleSetPath(Language.VBNET, @"c:\Solution\sln.ruleset");
            ProjectBindingOperation testSubject = this.CreateTestSubject();

            this.projectMock.SetVBProjectKind();
            PropertyMock customRuleSetProperty1 = CreateProperty(this.projectMock, "config1", "Custom.ruleset");
            PropertyMock customRuleSetProperty2 = CreateProperty(this.projectMock, "config2", "Custom.ruleset");

            testSubject.Initialize();

            // Act
            testSubject.Prepare(CancellationToken.None);

            // Verify
            string expectedRuleSetFileForPropertiesWithDefaultRulSets = Path.Combine(Path.GetDirectoryName(this.projectMock.FilePath), Path.GetFileNameWithoutExtension(this.projectMock.FilePath) + ".ruleset");

            this.sccFileSystem.AssertFileNotExists(expectedRuleSetFileForPropertiesWithDefaultRulSets);
            Assert.AreEqual(expectedRuleSetFileForPropertiesWithDefaultRulSets, testSubject.PropertyInformationMap[customRuleSetProperty1].NewRuleSetFilePath, "Expected different rule set path for properties with custom rulesets");
            Assert.AreEqual(expectedRuleSetFileForPropertiesWithDefaultRulSets, testSubject.PropertyInformationMap[customRuleSetProperty2].NewRuleSetFilePath, "Expected different rule set path for properties with custom rulesets");

            // Act (write pending)
            this.sccFileSystem.WritePendingNoErrorsExpected();

            // Verify that written
            this.sccFileSystem.AssertFileExists(expectedRuleSetFileForPropertiesWithDefaultRulSets);
        }
Example #3
0
        public void ProjectBindingOperation_Commit_NewProjectSystem_DoesNotAddFile()
        {
            // Arrange
            ProjectBindingOperation testSubject = this.CreateTestSubject();

            this.projectMock.SetCSProjectKind();
            this.ruleStore.RegisterConfigFilePath(Language.CSharp, @"c:\Solution\sln.ruleset");
            PropertyMock prop = CreateProperty(this.projectMock, "config1", ProjectBindingOperation.DefaultProjectRuleSet);

            testSubject.Initialize();
            testSubject.Prepare(CancellationToken.None);

            this.projectSystemHelper.SetIsLegacyProjectSystem(false);

            // Act
            using (new AssertIgnoreScope()) // Ignore that the file is not on disk
            {
                testSubject.Commit();
            }

            // Assert
            string expectedFile = Path.Combine(Path.GetDirectoryName(this.projectMock.FilePath), Path.GetFileNameWithoutExtension(this.projectMock.FilePath) + ".ruleset");

            prop.Value.ToString().Should().Be(Path.GetFileName(expectedFile), "Should update the property value");
            this.projectMock.Files.ContainsKey(expectedFile).Should().BeFalse("Should not add the file to the project for the new project system");
        }
Example #4
0
        public void ProjectBindingOperation_Commit()
        {
            // Setup
            this.serviceProvider.RegisterService(typeof(IProjectSystemHelper), this.projectSystemHelper);
            ProjectBindingOperation testSubject = this.CreateTestSubject();

            this.projectMock.SetCSProjectKind();
            this.ruleStore.RegisterRuleSetPath(Language.CSharp, @"c:\Solution\sln.ruleset");
            PropertyMock prop = CreateProperty(this.projectMock, "config1", ProjectBindingOperation.DefaultProjectRuleSet);

            testSubject.Initialize();
            testSubject.Prepare(CancellationToken.None);

            // Act
            using (new AssertIgnoreScope()) // Ignore that the file is not on disk
            {
                testSubject.Commit();
            }

            // Verify
            string expectedFile = Path.Combine(Path.GetDirectoryName(this.projectMock.FilePath), Path.GetFileNameWithoutExtension(this.projectMock.FilePath) + ".ruleset");

            Assert.AreEqual(Path.GetFileName(expectedFile), prop.Value.ToString(), "Should update the property value");
            Assert.IsTrue(this.projectMock.Files.ContainsKey(expectedFile), "Should be added to the project");
        }
Example #5
0
        public void ProjectBindingOperation_Prepare_SameDefaultRuleSetsInProject()
        {
            // Arrange
            this.ruleStore.RegisterConfigFilePath(Language.VBNET, @"c:\Solution\sln.ruleset");
            ProjectBindingOperation testSubject = this.CreateTestSubject();

            this.projectMock.SetVBProjectKind();
            PropertyMock defaultRuleSetProperty1 = CreateProperty(this.projectMock, "config1", ProjectBindingOperation.DefaultProjectRuleSet);
            PropertyMock defaultRuleSetProperty2 = CreateProperty(this.projectMock, "config2", ProjectBindingOperation.DefaultProjectRuleSet);

            testSubject.Initialize();

            // Act
            testSubject.Prepare(CancellationToken.None);


            // Assert
            string expectedRuleSetFileForPropertiesWithDefaultRulSets = Path.Combine(Path.GetDirectoryName(this.projectMock.FilePath), Path.GetFileNameWithoutExtension(this.projectMock.FilePath) + ".ruleset");

            fileSystem.GetFile(expectedRuleSetFileForPropertiesWithDefaultRulSets).Should().Be(null);
            testSubject.PropertyInformationMap[defaultRuleSetProperty1].NewRuleSetFilePath.Should().Be(expectedRuleSetFileForPropertiesWithDefaultRulSets, "Expected different rule set path for properties with custom rulesets");
            testSubject.PropertyInformationMap[defaultRuleSetProperty2].NewRuleSetFilePath.Should().Be(expectedRuleSetFileForPropertiesWithDefaultRulSets, "Expected different rule set path for properties with custom rulesets");

            // Act (write pending)
            this.sccFileSystem.WritePendingNoErrorsExpected();

            // Assert that written
            fileSystem.GetFile(expectedRuleSetFileForPropertiesWithDefaultRulSets).Should().NotBe(null);
        }
        public void ProjectBindingOperation_Prepare_SameDefaultRuleSetsInProject()
        {
            // Arrange
            CSharpVBBindingOperation testSubject = this.CreateTestSubject();

            this.projectMock.SetVBProjectKind();
            PropertyMock firstRuleSet  = CreateRuleSetProperty(this.projectMock, "config1", "MyCustomRuleSet.ruleset");
            PropertyMock secondRuleSet = CreateRuleSetProperty(this.projectMock, "config2", "MyCustomRuleSet.ruleset");

            testSubject.Initialize();

            // Act
            testSubject.Prepare(CancellationToken.None);


            // Assert
            string expectedRuleSetFileForPropertiesWithDefaultRuleSets = Path.Combine(Path.GetDirectoryName(this.projectMock.FilePath), Path.GetFileNameWithoutExtension(this.projectMock.FilePath) + ".ruleset");

            fileSystem.GetFile(expectedRuleSetFileForPropertiesWithDefaultRuleSets).Should().Be(null);
            testSubject.PropertyInformationMap[firstRuleSet].NewRuleSetFilePath.Should().Be(expectedRuleSetFileForPropertiesWithDefaultRuleSets, "Expected different rule set path for properties with custom rulesets");
            testSubject.PropertyInformationMap[secondRuleSet].NewRuleSetFilePath.Should().Be(expectedRuleSetFileForPropertiesWithDefaultRuleSets, "Expected different rule set path for properties with custom rulesets");

            // Act (write pending)
            this.sccFileSystem.WritePendingNoErrorsExpected();

            // Assert that written
            fileSystem.GetFile(expectedRuleSetFileForPropertiesWithDefaultRuleSets).Should().NotBe(null);
        }
        public void ProjectBindingOperation_Prepare_Cancellation()
        {
            // Arrange
            CSharpVBBindingOperation testSubject = this.CreateTestSubject();

            this.projectMock.SetCSProjectKind();
            PropertyMock prop = CreateRuleSetProperty(this.projectMock, "config1", CSharpVBBindingOperation.DefaultProjectRuleSet);

            testSubject.Initialize();
            using (CancellationTokenSource src = new CancellationTokenSource())
            {
                CancellationToken token = src.Token;
                src.Cancel();

                // Act
                testSubject.Prepare(token);
            }

            // Assert
            string expectedFile = Path.Combine(Path.GetDirectoryName(this.projectMock.FilePath), Path.GetFileNameWithoutExtension(this.projectMock.FilePath) + ".ruleset");

            testSubject.PropertyInformationMap[prop].NewRuleSetFilePath.Should().BeNull("Not expecting the new rule set path to be set when canceled");
            prop.Value.ToString().Should().Be(CSharpVBBindingOperation.DefaultProjectRuleSet, "Should not update the property value");
            this.projectMock.Files.ContainsKey(expectedFile).Should().BeFalse("Should not be added to the project");
        }
        public void ProjectBindingOperation_Commit_LegacyProjectSystem_DoesAddFile()
        {
            // Arrange
            CSharpVBBindingOperation testSubject = this.CreateTestSubject();

            this.projectMock.SetCSProjectKind();
            PropertyMock prop = CreateRuleSetProperty(this.projectMock, "config1", "MyCustomRuleSet.ruleset");

            testSubject.Initialize();
            testSubject.Prepare(CancellationToken.None);

            this.projectSystemHelper.SetIsLegacyProjectSystem(true);

            // Act
            using (new AssertIgnoreScope()) // Ignore that the file is not on disk
            {
                testSubject.Commit();
            }

            // Assert
            string projectFile = Path.Combine(Path.GetDirectoryName(this.projectMock.FilePath), Path.GetFileNameWithoutExtension(this.projectMock.FilePath) + ".ruleset");

            prop.Value.ToString().Should().Be(Path.GetFileName(projectFile), "Should update the property value");
            this.projectMock.Files.ContainsKey(projectFile).Should().BeTrue("Should add the file to the project for the legacy project system");
        }
Example #9
0
        // The contents of this class were created by the Mocklis code-generator.
        // Any changes you make will be overwritten if the contents are re-generated.

        public TestClass()
        {
            Property = new PropertyMock <int>(this, "TestClass", "ITestClass", "Property", "Property", Strictness.VeryStrict);
            Item     = new IndexerMock <int, string>(this, "TestClass", "ITestClass", "this[]", "Item", Strictness.VeryStrict);
            MyMethod = new FuncMethodMock <string, string>(this, "TestClass", "ITestClass", "MyMethod", "MyMethod", Strictness.VeryStrict);
            MyEvent  = new EventMock <EventHandler>(this, "TestClass", "ITestClass", "MyEvent", "MyEvent", Strictness.VeryStrict);
        }
        // The contents of this class were created by the Mocklis code-generator.
        // Any changes you make will be overwritten if the contents are re-generated.

        public MockPropertiesWithChangeNotification()
        {
            StringProperty   = new PropertyMock <string>(this, "MockPropertiesWithChangeNotification", "IProperties", "StringProperty", "StringProperty", Strictness.Lenient);
            IntProperty      = new PropertyMock <int>(this, "MockPropertiesWithChangeNotification", "IProperties", "IntProperty", "IntProperty", Strictness.Lenient);
            BoolProperty     = new PropertyMock <bool>(this, "MockPropertiesWithChangeNotification", "IProperties", "BoolProperty", "BoolProperty", Strictness.Lenient);
            DateTimeProperty = new PropertyMock <System.DateTime>(this, "MockPropertiesWithChangeNotification", "IProperties", "DateTimeProperty", "DateTimeProperty", Strictness.Lenient);
            PropertyChanged  = new EventMock <PropertyChangedEventHandler>(this, "MockPropertiesWithChangeNotification", "INotifyPropertyChanged", "PropertyChanged", "PropertyChanged", Strictness.Lenient);
        }
Example #11
0
        // The contents of this class were created by the Mocklis code-generator.
        // Any changes you make will be overwritten if the contents are re-generated.

        public MockMembers()
        {
            MyEvent        = new EventMock <EventHandler>(this, "MockMembers", "IMembers", "MyEvent", "MyEvent", Strictness.Lenient);
            Item           = new IndexerMock <int, string>(this, "MockMembers", "IMembers", "this[]", "Item", Strictness.Lenient);
            DoStuff        = new ActionMethodMock(this, "MockMembers", "IMembers", "DoStuff", "DoStuff", Strictness.Lenient);
            Calculate      = new FuncMethodMock <(int value1, int value2), int>(this, "MockMembers", "IMembers", "Calculate", "Calculate", Strictness.Lenient);
            StringProperty = new PropertyMock <string>(this, "MockMembers", "IMembers", "StringProperty", "StringProperty", Strictness.Lenient);
        }
Example #12
0
 protected TestClass()
 {
     NormalProperty            = new PropertyMock <string?>(this, "TestClass", "ITestClass", "NormalProperty", "NormalProperty", Strictness.Lenient);
     Item                      = new IndexerMock <string?, string?>(this, "TestClass", "ITestClass", "this[]", "Item", Strictness.Lenient);
     NonNullableEvent          = new EventMock <EventHandler>(this, "TestClass", "ITestClass", "NonNullableEvent", "NonNullableEvent", Strictness.Lenient);
     Method3                   = new FuncMethodMock <(string?p1, string?p2), string?>(this, "TestClass", "ITestClass", "Method3", "Method3", Strictness.Lenient);
     ValueTypeProperty         = new PropertyMock <int>(this, "TestClass", "ITestClass", "ValueTypeProperty", "ValueTypeProperty", Strictness.Lenient);
     NullableValueTypeProperty = new PropertyMock <int?>(this, "TestClass", "ITestClass", "NullableValueTypeProperty", "NullableValueTypeProperty", Strictness.Lenient);
 }
        // The contents of this class were created by the Mocklis code-generator.
        // Any changes you make will be overwritten if the contents are re-generated.

        public TestClass()
        {
            DataReceived = new EventMock <EventHandler <DuplexConnectionDataEventArgs> >(this, "TestClass", "IDuplexConnection", "DataReceived", "DataReceived", Strictness.Lenient);
            TextReceived = new EventMock <EventHandler <DuplexConnectionTextEventArgs> >(this, "TestClass", "IDuplexConnection", "TextReceived", "TextReceived", Strictness.Lenient);
            SendData     = new ActionMethodMock <byte[]>(this, "TestClass", "IDuplexConnection", "SendData", "SendData", Strictness.Lenient);
            SendText     = new ActionMethodMock <string>(this, "TestClass", "IDuplexConnection", "SendText", "SendText", Strictness.Lenient);
            Close        = new FuncMethodMock <string, Task <string> >(this, "TestClass", "IDuplexConnection", "Close", "Close", Strictness.Lenient);
            Run          = new FuncMethodMock <Task>(this, "TestClass", "IDuplexConnection", "Run", "Run", Strictness.Lenient);
            SubProtocol  = new PropertyMock <string>(this, "TestClass", "IDuplexConnection", "SubProtocol", "SubProtocol", Strictness.Lenient);
        }
 protected TestClass()
 {
     NullableProperty = new PropertyMock <string?>(this, "TestClass", "ITestClass", "NullableProperty", "NullableProperty", Strictness.Lenient);
     NormalProperty   = new PropertyMock <string>(this, "TestClass", "ITestClass", "NormalProperty", "NormalProperty", Strictness.Lenient);
     Item             = new IndexerMock <int, string?>(this, "TestClass", "ITestClass", "this[]", "Item", Strictness.Lenient);
     Item0            = new IndexerMock <bool, string>(this, "TestClass", "ITestClass", "this[]", "Item0", Strictness.Lenient);
     Item1            = new IndexerMock <string?, string?>(this, "TestClass", "ITestClass", "this[]", "Item1", Strictness.Lenient);
     Item2            = new IndexerMock <(int i, string?s), string>(this, "TestClass", "ITestClass", "this[]", "Item2", Strictness.Lenient);
     NonNullableEvent = new EventMock <EventHandler>(this, "TestClass", "ITestClass", "NonNullableEvent", "NonNullableEvent", Strictness.Lenient);
     NullableEvent    = new EventMock <EventHandler>(this, "TestClass", "ITestClass", "NullableEvent", "NullableEvent", Strictness.Lenient);
     Method1          = new FuncMethodMock <string?, string>(this, "TestClass", "ITestClass", "Method1", "Method1", Strictness.Lenient);
     Method2          = new FuncMethodMock <string, string?>(this, "TestClass", "ITestClass", "Method2", "Method2", Strictness.Lenient);
     Method3          = new FuncMethodMock <(string p1, string?p2), string>(this, "TestClass", "ITestClass", "Method3", "Method3", Strictness.Lenient);
 }
Example #15
0
        // The contents of this class were created by the Mocklis code-generator.
        // Any changes you make will be overwritten if the contents are re-generated.

        public MockMembers()
        {
            MyEvent             = new EventMock <EventHandler>(this, "MockMembers", "IEvents", "MyEvent", "MyEvent", Strictness.Lenient);
            SpecialEvent        = new EventMock <EventHandler <SpecialEventArgs> >(this, "MockMembers", "IEvents", "SpecialEvent", "SpecialEvent", Strictness.Lenient);
            SimpleAction        = new ActionMethodMock(this, "MockMembers", "IMethods", "SimpleAction", "SimpleAction", Strictness.Lenient);
            ActionWithParameter = new ActionMethodMock <int>(this, "MockMembers", "IMethods", "ActionWithParameter", "ActionWithParameter", Strictness.Lenient);
            SimpleFunc          = new FuncMethodMock <int>(this, "MockMembers", "IMethods", "SimpleFunc", "SimpleFunc", Strictness.Lenient);
            FuncWithParameter   = new FuncMethodMock <int, int>(this, "MockMembers", "IMethods", "FuncWithParameter", "FuncWithParameter", Strictness.Lenient);
            StringProperty      = new PropertyMock <string>(this, "MockMembers", "IProperties", "StringProperty", "StringProperty", Strictness.Lenient);
            IntProperty         = new PropertyMock <int>(this, "MockMembers", "IProperties", "IntProperty", "IntProperty", Strictness.Lenient);
            BoolProperty        = new PropertyMock <bool>(this, "MockMembers", "IProperties", "BoolProperty", "BoolProperty", Strictness.Lenient);
            DateTimeProperty    = new PropertyMock <DateTime>(this, "MockMembers", "IProperties", "DateTimeProperty", "DateTimeProperty", Strictness.Lenient);
            Item  = new IndexerMock <int, string>(this, "MockMembers", "IIndexers", "this[]", "Item", Strictness.Lenient);
            Item0 = new IndexerMock <bool, DateTime>(this, "MockMembers", "IIndexers", "this[]", "Item0", Strictness.Lenient);
        }
        // The contents of this class were created by the Mocklis code-generator.
        // Any changes you make will be overwritten if the contents are re-generated.

        public TestClass()
        {
            ContainsKey    = new FuncMethodMock <TKey, bool>(this, "TestClass", "IDictionary", "ContainsKey", "ContainsKey", Strictness.Lenient);
            Add            = new ActionMethodMock <(TKey key, TValue value)>(this, "TestClass", "IDictionary", "Add", "Add", Strictness.Lenient);
            Remove         = new FuncMethodMock <TKey, bool>(this, "TestClass", "IDictionary", "Remove", "Remove", Strictness.Lenient);
            TryGetValue    = new FuncMethodMock <TKey, (bool returnValue, TValue value)>(this, "TestClass", "IDictionary", "TryGetValue", "TryGetValue", Strictness.Lenient);
            Item           = new IndexerMock <TKey, TValue>(this, "TestClass", "IDictionary", "this[]", "Item", Strictness.Lenient);
            Keys           = new PropertyMock <ICollection <TKey> >(this, "TestClass", "IDictionary", "Keys", "Keys", Strictness.Lenient);
            Values         = new PropertyMock <ICollection <TValue> >(this, "TestClass", "IDictionary", "Values", "Values", Strictness.Lenient);
            Add0           = new ActionMethodMock <KeyValuePair <TKey, TValue> >(this, "TestClass", "ICollection", "Add", "Add0", Strictness.Lenient);
            Clear          = new ActionMethodMock(this, "TestClass", "ICollection", "Clear", "Clear", Strictness.Lenient);
            Contains       = new FuncMethodMock <KeyValuePair <TKey, TValue>, bool>(this, "TestClass", "ICollection", "Contains", "Contains", Strictness.Lenient);
            CopyTo         = new ActionMethodMock <(KeyValuePair <TKey, TValue>[] array, int arrayIndex)>(this, "TestClass", "ICollection", "CopyTo", "CopyTo", Strictness.Lenient);
            Remove0        = new FuncMethodMock <KeyValuePair <TKey, TValue>, bool>(this, "TestClass", "ICollection", "Remove", "Remove0", Strictness.Lenient);
            Count          = new PropertyMock <int>(this, "TestClass", "ICollection", "Count", "Count", Strictness.Lenient);
            IsReadOnly     = new PropertyMock <bool>(this, "TestClass", "ICollection", "IsReadOnly", "IsReadOnly", Strictness.Lenient);
            GetEnumerator  = new FuncMethodMock <IEnumerator <KeyValuePair <TKey, TValue> > >(this, "TestClass", "IEnumerable", "GetEnumerator", "GetEnumerator", Strictness.Lenient);
            GetEnumerator0 = new FuncMethodMock <System.Collections.IEnumerator>(this, "TestClass", "IEnumerable", "GetEnumerator", "GetEnumerator0", Strictness.Lenient);
        }
        public void ProjectBindingOperation_Prepare_VariousRuleSetsInProjects()
        {
            // Arrange
            CSharpVBBindingOperation testSubject = this.CreateTestSubject();

            this.projectMock.SetVBProjectKind();
            PropertyMock customRuleSetProperty1  = CreateRuleSetProperty(this.projectMock, "config1", "Custom.ruleset");
            PropertyMock customRuleSetProperty2  = CreateRuleSetProperty(this.projectMock, "config2", "Custom.ruleset");
            PropertyMock defaultRuleSetProperty1 = CreateRuleSetProperty(this.projectMock, "config3", CSharpVBBindingOperation.DefaultProjectRuleSet);
            PropertyMock defaultRuleSetProperty2 = CreateRuleSetProperty(this.projectMock, "config4", CSharpVBBindingOperation.DefaultProjectRuleSet);

            testSubject.Initialize();

            // Act
            testSubject.Prepare(CancellationToken.None);

            // Assert
            string expectedRuleSetFileForPropertiesWithDefaultRuleSets = cSharpVBBindingConfig.RuleSet.Path;

            fileSystem.GetFile(expectedRuleSetFileForPropertiesWithDefaultRuleSets).Should().NotBe(null);
            testSubject.PropertyInformationMap[defaultRuleSetProperty1].NewRuleSetFilePath.Should().Be(expectedRuleSetFileForPropertiesWithDefaultRuleSets, "Expected all the properties with default ruleset to have the same new ruleset");
            testSubject.PropertyInformationMap[defaultRuleSetProperty2].NewRuleSetFilePath.Should().Be(expectedRuleSetFileForPropertiesWithDefaultRuleSets, "Expected all the properties with default ruleset to have the same new ruleset");

            string expectedRulesetFilePath = Path.Combine(Path.GetDirectoryName(this.projectMock.FilePath), Path.GetFileNameWithoutExtension(this.projectMock.FilePath) + ".ruleset");

            string expectedRuleSetForConfig1 = Path.ChangeExtension(expectedRulesetFilePath, "config1.ruleset");

            testSubject.PropertyInformationMap[customRuleSetProperty1].NewRuleSetFilePath.Should().Be(expectedRuleSetForConfig1, "Expected different rule set path for properties with custom rulesets");
            fileSystem.GetFile(expectedRuleSetForConfig1).Should().Be(null);

            string expectedRuleSetForConfig2 = Path.ChangeExtension(expectedRulesetFilePath, "config2.ruleset");

            testSubject.PropertyInformationMap[customRuleSetProperty2].NewRuleSetFilePath.Should().Be(expectedRuleSetForConfig2, "Expected different rule set path for properties with custom rulesets");
            fileSystem.GetFile(expectedRuleSetForConfig2).Should().Be(null);

            // Act (write pending)
            this.sccFileSystem.WritePendingNoErrorsExpected();

            // Assert that written
            fileSystem.GetFile(expectedRuleSetForConfig1).Should().NotBe(null);
            fileSystem.GetFile(expectedRuleSetForConfig2).Should().NotBe(null);
        }
        public void ProjectBindingOperation_Initialize_ConfigurationPropertiesWithVariousValues()
        {
            // Arrange
            CSharpVBBindingOperation testSubject = this.CreateTestSubject();

            this.projectMock.SetCSProjectKind();
            PropertyMock prop1 = CreateRuleSetProperty(this.projectMock, "config1", CSharpVBBindingOperation.DefaultProjectRuleSet);
            PropertyMock prop2 = CreateRuleSetProperty(this.projectMock, "config2", "NonDefualtRuleSet.ruleset");

            // Act
            testSubject.Initialize();

            // Assert
            testSubject.ProjectFullPath.Should().Be(@"c:\solution\Project\project.proj");
            testSubject.ProjectLanguage.Should().Be(Language.CSharp);
            CollectionAssert.AreEquivalent(new[] { prop1, prop2 }, testSubject.PropertyInformationMap.Keys.ToArray(), "Unexpected properties");

            testSubject.PropertyInformationMap[prop1].CurrentRuleSetFilePath.Should().Be(CSharpVBBindingOperation.DefaultProjectRuleSet);
            testSubject.PropertyInformationMap[prop1].TargetRuleSetFileName.Should().Be("project", "Default ruleset - expected project based name to be generated");
            testSubject.PropertyInformationMap[prop2].CurrentRuleSetFilePath.Should().Be("NonDefualtRuleSet.ruleset");
            testSubject.PropertyInformationMap[prop2].TargetRuleSetFileName.Should().Be("project.config2", "Non default ruleset - expected configuration based rule set name to be generated");
        }
Example #19
0
        public void ProjectBindingOperation_Initialize_ConfigurationPropertyWithDefaultValues()
        {
            // Setup
            ProjectBindingOperation testSubject = this.CreateTestSubject();

            this.projectMock.SetVBProjectKind();
            PropertyMock prop1 = CreateProperty(this.projectMock, "config1", ProjectBindingOperation.DefaultProjectRuleSet);
            PropertyMock prop2 = CreateProperty(this.projectMock, "config2", ProjectBindingOperation.DefaultProjectRuleSet);

            // Act
            testSubject.Initialize();

            // Verify
            Assert.AreEqual(@"c:\solution\Project\project.proj", testSubject.ProjectFullPath);
            Assert.AreEqual(Language.VBNET, testSubject.ProjectLanguage);
            CollectionAssert.AreEquivalent(new[] { prop1, prop2 }, testSubject.PropertyInformationMap.Keys.ToArray(), "Unexpected properties");

            foreach (var prop in new[] { prop1, prop2 })
            {
                Assert.AreEqual(ProjectBindingOperation.DefaultProjectRuleSet, testSubject.PropertyInformationMap[prop].CurrentRuleSetFilePath);
                Assert.AreEqual("project", testSubject.PropertyInformationMap[prop].TargetRuleSetFileName);
            }
        }
        public void ProjectBindingOperation_Initialize_ConfigurationPropertyWithSameNonDefaultValues()
        {
            // Arrange
            CSharpVBBindingOperation testSubject = this.CreateTestSubject();

            this.projectMock.SetVBProjectKind();
            PropertyMock prop1 = CreateRuleSetProperty(this.projectMock, "config1", "Custom1.ruleset");
            PropertyMock prop2 = CreateRuleSetProperty(this.projectMock, "config2", "Custom1.ruleset");

            // Act
            testSubject.Initialize();

            // Assert
            testSubject.ProjectFullPath.Should().Be(@"c:\solution\Project\project.proj");
            testSubject.ProjectLanguage.Should().Be(Language.VBNET);
            CollectionAssert.AreEquivalent(new[] { prop1, prop2 }, testSubject.PropertyInformationMap.Keys.ToArray(), "Unexpected properties");

            foreach (var prop in new[] { prop1, prop2 })
            {
                testSubject.PropertyInformationMap[prop].CurrentRuleSetFilePath.Should().Be("Custom1.ruleset");
                testSubject.PropertyInformationMap[prop].TargetRuleSetFileName.Should().Be("project");
            }
        }
Example #21
0
        public void ProjectBindingOperation_Initialize_ConfigurationPropertyWithEmptyRuleSets()
        {
            // Arrange
            ProjectBindingOperation testSubject = this.CreateTestSubject();

            this.projectMock.SetVBProjectKind();
            PropertyMock prop1 = CreateProperty(this.projectMock, "config1", null);
            PropertyMock prop2 = CreateProperty(this.projectMock, "config2", string.Empty);

            // Act
            testSubject.Initialize();

            // Assert
            testSubject.ProjectFullPath.Should().Be(@"c:\solution\Project\project.proj");
            testSubject.ProjectLanguage.Should().Be(Language.VBNET);
            CollectionAssert.AreEquivalent(new[] { prop1, prop2 }, testSubject.PropertyInformationMap.Keys.ToArray(), "Unexpected properties");

            foreach (var prop in new[] { prop1, prop2 })
            {
                string.IsNullOrEmpty(testSubject.PropertyInformationMap[prop].CurrentRuleSetFilePath).Should().BeTrue();
                testSubject.PropertyInformationMap[prop].TargetRuleSetFileName.Should().Be("project");
            }
        }
Example #22
0
 public PropertyDomainTest(DatabaseFixture fixture)
 {
     _fixture = fixture;
     OwnerMock.Instance().AddOwners(_fixture);
     PropertyMock.Instance().AddProperties(_fixture);
 }
        // The contents of this class were created by the Mocklis code-generator.
        // Any changes you make will be overwritten if the contents are re-generated.

        public TestClass()
        {
            Normal = new PropertyMock <int>(this, "TestClass", "ITestClass", "Normal", "Normal", Strictness.Lenient);
        }
Example #24
0
 public MissingPropertyStepGetTests()
 {
     _propertyMock        = new PropertyMock <int>(new object(), "TestClass", "ITest", "Indexer", "Indexer1", Strictness.Lenient);
     _missingPropertyStep = MissingPropertyStep <int> .Instance;
 }
Example #25
0
        // The contents of this class were created by the Mocklis code-generator.
        // Any changes you make will be overwritten if the contents are re-generated.

        public TestClass()
        {
            GetAndSet = new PropertyMock <int>(this, "TestClass", "ITestClass", "GetAndSet", "GetAndSet", Strictness.Lenient);
            SetOnly   = new PropertyMock <int>(this, "TestClass", "ITestClass", "SetOnly", "SetOnly", Strictness.Lenient);
            GetOnly   = new PropertyMock <int>(this, "TestClass", "ITestClass", "GetOnly", "GetOnly", Strictness.Lenient);
        }
Example #26
0
        // The contents of this class were created by the Mocklis code-generator.
        // Any changes you make will be overwritten if the contents are re-generated.

        public TestClass()
        {
            GetAndSet = new PropertyMock <T>(this, "TestClass", "ITestClass", "GetAndSet", "GetAndSet", Strictness.Lenient);
        }
        // The contents of this class were created by the Mocklis code-generator.
        // Any changes you make will be overwritten if the contents are re-generated.

        public TestClass()
        {
            Test0        = new FuncMethodMock <int, string>(this, "TestClass", "ITestClass", "Test", "Test0", Strictness.Lenient);
            AnotherTest0 = new PropertyMock <bool>(this, "TestClass", "ITestClass", "AnotherTest", "AnotherTest0", Strictness.Lenient);
        }
Example #28
0
        // The contents of this class were created by the Mocklis code-generator.
        // Any changes you make will be overwritten if the contents are re-generated.

        public TestClass()
        {
            Property1   = new PropertyMock <int>(this, "TestClass", "ITest1", "Property1", "Property1", Strictness.Lenient);
            DoSomething = new ActionMethodMock <string>(this, "TestClass", "ITest2", "DoSomething", "DoSomething", Strictness.Lenient);
        }
Example #29
0
        // The contents of this class were created by the Mocklis code-generator.
        // Any changes you make will be overwritten if the contents are re-generated.

        protected TestClass()
        {
            Test = new PropertyMock <int>(this, "TestClass", "ITestClass", "Test", "Test", Strictness.Lenient);
        }
Example #30
0
 protected TestClass()
 {
     Property = new PropertyMock <T?>(this, "TestClass", "ITestClass", "Property", "Property", Strictness.Lenient);
     Item     = new IndexerMock <(T?p1, T?p2), T?>(this, "TestClass", "ITestClass", "this[]", "Item", Strictness.Lenient);
     Test     = new FuncMethodMock <T?, T?>(this, "TestClass", "ITestClass", "Test", "Test", Strictness.Lenient);
 }