Example #1
0
        public void Should_assertions()
        {
            object obj = null;
            obj.ShouldBeNull();

            obj = new object();
            obj.ShouldBeType(typeof(object));
            obj.ShouldEqual(obj);
            obj.ShouldNotBeNull();
            obj.ShouldNotBeSameAs(new object());
            obj.ShouldNotBeType(typeof(string));
            obj.ShouldNotEqual("foo");

            obj = "x";
            obj.ShouldNotBeInRange("y", "z");
            obj.ShouldBeInRange("a", "z");
            obj.ShouldBeSameAs("x");

            "This String".ShouldContain("This");
            "This String".ShouldNotBeEmpty();
            "This String".ShouldNotContain("foobar");

            false.ShouldBeFalse();
            true.ShouldBeTrue();

            var list = new List<object>();
            list.ShouldBeEmpty();
            list.ShouldNotContain(new object());

            var item = new object();
            list.Add(item);
            list.ShouldNotBeEmpty();
            list.ShouldContain(item);
        }
 public void ShouldBeEmpty()
 {
     DocExampleWriter.Document(() =>
     {
         var homer = new Person() { Name = "Homer" };
         var powerPlantOnTheWeekend = new List<Person>() { homer };
         powerPlantOnTheWeekend.ShouldBeEmpty();
     }, _testOutputHelper);
 }
 public void Should_pass_for_config_with_unknown_section()
 {
     const string xmlRules = @"
     <Rules>
       <NonExistingId />
       <Dummy />
     </Rules>
     ";
     var newConfigFileContent = string.Empty;
     Action<string, byte[]> saveConfigFileAction = (s, bytes) =>
     {
         newConfigFileContent = Encoding.UTF8.GetString(bytes);
     };
     var instance = CreateInstance(saveConfigFileAction);
     var errors = new List<string>();
     instance.Parse("SolutionCop.xml", xmlRules, new IProjectRule[] { new DummyRule() }, errors);
     errors.ShouldBeEmpty();
     newConfigFileContent.ShouldBeEmpty();
 }
 public void Should_pass_for_empty_config()
 {
     const string xmlRules = @"<Rules></Rules>";
     var newConfigFileContent = string.Empty;
     Action<string, byte[]> saveConfigFileAction = (s, bytes) =>
     {
         newConfigFileContent = Encoding.UTF8.GetString(bytes);
     };
     var instance = CreateInstance(saveConfigFileAction);
     var errors = new List<string>();
     instance.Parse("SolutionCop.xml", xmlRules, new IProjectRule[] { new DummyRule() }, errors);
     errors.ShouldBeEmpty();
     newConfigFileContent.ShouldNotBeEmpty();
     Approvals.Verify(newConfigFileContent);
 }