public void ShouldThrowWhenNullPassedToShouldBeAssignable()
        {
            MyThing myThing = null;

            // ReSharper disable once ExpressionIsAlwaysNull
            Verify.ShouldFail(() =>
                              myThing.ShouldBeAssignableTo <MyBase>("Some additional context"),

                              errorWithSource:
                              @"myThing
    should be assignable to
Shouldly.Tests.TestHelpers.MyBase
    but was
null

Additional Info:
    Some additional context",

                              errorWithoutSource:
                              @"null
    should be assignable to
Shouldly.Tests.TestHelpers.MyBase
    but was not

Additional Info:
    Some additional context");
        }
        protected override void ShouldThrowAWobbly()
        {
            MyThing myThing = null;

            // ReSharper disable once ExpressionIsAlwaysNull
            myThing.ShouldBeAssignableTo <MyBase>("Some additional context");
        }
        public void DerivedTypeScenarioShouldFail()
        {
            var myThing = new MyThing();
            Verify.ShouldFail(() =>
myThing.ShouldBeAssignableTo<string>("Some additional context"),

errorWithSource:
@"myThing
    should be assignable to
System.String
    but was
Shouldly.Tests.TestHelpers.MyThing

Additional Info:
    Some additional context",

errorWithoutSource:
@"Shouldly.Tests.TestHelpers.MyThing (000000)
    should be assignable to
System.String
    but was
Shouldly.Tests.TestHelpers.MyThing

Additional Info:
    Some additional context");
        }
        public void DerivedTypeScenarioShouldFail()
        {
            var myThing = new MyThing();
            // ReSharper disable once ExpressionIsAlwaysNull
            Verify.ShouldFail(() =>
myThing.ShouldBeOfType<MyBase>("Some additional context"),

errorWithSource:
@"myThing
    should be of type
Shouldly.Tests.TestHelpers.MyBase
    but was
Shouldly.Tests.TestHelpers.MyThing

Additional Info:
    Some additional context",

errorWithoutSource:
@"Shouldly.Tests.TestHelpers.MyThing (000000)
    should be of type
Shouldly.Tests.TestHelpers.MyBase
    but was
Shouldly.Tests.TestHelpers.MyThing

Additional Info:
    Some additional context");
        }
Example #5
0
        protected override void ShouldThrowAWobbly()
        {
            MyThing myThing = null;

            // ReSharper disable once ExpressionIsAlwaysNull
            myThing.ShouldBeOfType <MyBase>();
        }
        public void DerivedTypeScenarioShouldFail()
        {
            var myThing = new MyThing();
            Verify.ShouldFail(() =>
myThing.ShouldNotBeOfType<MyThing>("Some additional context"),

errorWithSource:
@"myThing
    should not be of type
Shouldly.Tests.TestHelpers.MyThing
    but was
Shouldly.Tests.TestHelpers.MyThing (000000)

Additional Info:
    Some additional context",

errorWithoutSource:
@"Shouldly.Tests.TestHelpers.MyThing (000000)
    should not be of type
Shouldly.Tests.TestHelpers.MyThing
    but was

Additional Info:
    Some additional context");
        }
 public void ApplyEvent(MyThing myThing, Event eventInfo)
 {
     // Get original from database or repository
     // Save and validate null
     // Store relevant information in _errors;
     // Change state
 }
Example #8
0
        public void ShouldThrowWhenNullPassedToShouldBeAssignableValueType()
        {
            MyThing myThing = null;

            // ReSharper disable once ExpressionIsAlwaysNull
            Verify.ShouldFail(() =>
                              myThing.ShouldBeAssignableTo <int>("Some additional context"),

                              errorWithSource:
                              @"myThing
    should be assignable to
System.Int32
    but was
null

Additional Info:
    Some additional context",

                              errorWithoutSource:
                              @"null
    should be assignable to
System.Int32
    but was not

Additional Info:
    Some additional context");
        }
Example #9
0
        public void DerivedTypeScenarioShouldFail()
        {
            var myThing = new MyThing();

            Verify.ShouldFail(() =>
                              myThing.ShouldNotBeOfType <MyThing>("Some additional context"),

                              errorWithSource:
                              @"myThing
    should not be of type
Shouldly.Tests.TestHelpers.MyThing
    but was
Shouldly.Tests.TestHelpers.MyThing (000000)

Additional Info:
    Some additional context",

                              errorWithoutSource:
                              @"Shouldly.Tests.TestHelpers.MyThing (000000)
    should not be of type
Shouldly.Tests.TestHelpers.MyThing
    but was

Additional Info:
    Some additional context");
        }
Example #10
0
        public void DerivedTypeScenarioShouldFail()
        {
            var myThing = new MyThing();

            Verify.ShouldFail(() =>
                              myThing.ShouldBeAssignableTo <string>("Some additional context"),

                              errorWithSource:
                              @"myThing
    should be assignable to
System.String
    but was
Shouldly.Tests.TestHelpers.MyThing

Additional Info:
    Some additional context",

                              errorWithoutSource:
                              @"Shouldly.Tests.TestHelpers.MyThing (000000)
    should be assignable to
System.String
    but was
Shouldly.Tests.TestHelpers.MyThing

Additional Info:
    Some additional context");
        }
Example #11
0
        public void ActualIsNullScenarioShouldFail()
        {
            MyThing myThing = null;

            // ReSharper disable once ExpressionIsAlwaysNull
            Verify.ShouldFail(() =>
                              myThing.ShouldBeOfType <MyBase>("Some additional context"),

                              errorWithSource:
                              @"myThing
    should be of type
Shouldly.Tests.TestHelpers.MyBase
    but was
null

Additional Info:
    Some additional context",

                              errorWithoutSource:
                              @"null
    should be of type
Shouldly.Tests.TestHelpers.MyBase
    but was not

Additional Info:
    Some additional context");
        }
Example #12
0
        public void DerivedTypeScenarioShouldFail()
        {
            var myThing = new MyThing();

            // ReSharper disable once ExpressionIsAlwaysNull
            Verify.ShouldFail(() =>
                              myThing.ShouldBeOfType <MyBase>("Some additional context"),

                              errorWithSource:
                              @"myThing
    should be of type
Shouldly.Tests.TestHelpers.MyBase
    but was
Shouldly.Tests.TestHelpers.MyThing

Additional Info:
    Some additional context",

                              errorWithoutSource:
                              @"Shouldly.Tests.TestHelpers.MyThing (000000)
    should be of type
Shouldly.Tests.TestHelpers.MyBase
    but was
Shouldly.Tests.TestHelpers.MyThing

Additional Info:
    Some additional context");
        }
    public void Main(string[] args)
    {
        MyThing a = new MyThing();
        MyThing b = new MyThing();

        a.SetValues(b);             //calls more specific
        a.SetValues((ISomething)b); //calls just the thing
    }
 public MyThing ApplyEvent(MyThing myThing, Event eventInfo)
 {
     if (mything == null)
     {
         // use null object pattern
         _errors.Add("Null value")
     }
 }
Example #15
0
        static void Main(string[] args)
        {
            // the type of this variable now is our method, which we can reuse
            MyThing multiplication = MultiplyThem;

            var result = multiplication(5, 5);

            Console.WriteLine(result);
        }
 public MyThing ApplyEvent(MyThing myThing, Event eventInfo)
 {
     if (mything == null)
     {
         // use null object pattern
         mything.AddErrors("Null value")
         // Based on the event, you select which state to instantiate
         // and inject dependencies
         mything.State = new OriginalNullState();
     }
 }
        public void OnGet(string trigger)
        {
            _logger.LogDebug($"DEBUG YO DEBUG Enabled={_logger.IsEnabled(LogLevel.Debug)}");

            _logger.LogInformation($"INFO YO DEBUG Enabled={_logger.IsEnabled(LogLevel.Debug)}");

            _logger.LogCritical($"CRIT YO DEBUG Enabled={_logger.IsEnabled(LogLevel.Debug)}");

            if (trigger != null)
            {
                MyThing.Update();
            }
        }
Example #18
0
    public override bool Equals(object obj)
    {
        if (obj == null)
        {
            return(false);
        }
        MyThing other = obj as MyThing;

        if (other == null)
        {
            return(false);
        }
        return(this.Text.Equals(other.Text));
    }
Example #19
0
        public void LessVerbose()
        {
            var writer =
                from root in XmlWrite.For <MyThing>().Tag("root")
                from myStringContent in root.Tag("string").Content(x => x.MyString)
                from myIntContent in root.Tag("int").Content(x => x.MyInt.ToString())
                select root;
            var expected = "<root><string>some text</string><int>42</int></root>";

            var thing = new MyThing {
                MyString = "some text", MyInt = 42
            };
            var actual = writer.Write(thing);

            Assert.Equal(expected, actual);
        }
Example #20
0
        public async void RunAsyncTest()
        {
            var api = Substitute.For<MyApi>();

            api.Request().Returns(
                Task.FromResult(1),
                Task.FromResult(1),
                Task.FromResult(3),
                Task.FromResult(1),
                Task.FromResult(1));

            var thing = new MyThing(api);

            Assert.AreEqual(7, await thing.RequestManyAndSum(5));

            api.Received(5).Request();
        }
Example #21
0
        public void ComposedFromObject()
        {
            var thing =
                new MyThing
            {
                Name  = "yep",
                Stuff = new[] { "42", "666" }
            };

            var writer =
                from root in XmlWrite.For <MyThing>().Tag("root")
                from name in root.Tag("name").Content(x => x.Name)
                from codes in root.Tag("codes")
                from sub in codes.Many(x => x.Stuff,
                                       from s in XmlWrite.For <string>().Tag("string")
                                       from c in s.Tag("code")
                                       from a in c.Attribute("value", x => x)
                                       select s)
                select root;
            var expected = "<root><name>yep</name><codes><string><code value=\"42\"/></string><string><code value=\"666\"/></string></codes></root>";
            var actual   = writer.Write(thing);

            Assert.Equal(expected, actual);
        }
Example #22
0
 protected MyClass(MyThing thing)
 {
     Contract.Requires(thing != null);
     this.MyThing = thing;
 }
 public void ShouldPass()
 {
     var myThing = new MyThing();
     myThing.ShouldNotBeAssignableTo<string>();
 }
Example #24
0
 protected override void ShouldPass()
 {
     var myThing = new MyThing();
     myThing.ShouldBeAssignableTo<MyBase>();
 }
Example #25
0
        public void ShouldPass()
        {
            var myThing = new MyThing();

            myThing.ShouldNotBeOfType <MyBase>();
        }
        protected override void ShouldPass()
        {
            var myThing = new MyThing();

            myThing.ShouldBeAssignableTo <MyBase>();
        }
Example #27
0
 public void NewTypedThing()
 {
     var x = new MyThing <int>("static");
 }
 protected override void ShouldThrowAWobbly()
 {
     var myThing = new MyThing();
     myThing.ShouldBeOfType<MyBase>("Some additional context");
 }
 public void ShouldPass()
 {
     var myThing = new MyThing();
     myThing.ShouldNotBeOfType<MyBase>();
 }
        protected override void ShouldThrowAWobbly()
        {
            var myThing = new MyThing();

            myThing.ShouldNotBeOfType <MyThing>();
        }
 protected override void ShouldPass()
 {
     var myThing = new MyThing();
     myThing.ShouldNotBeAssignableTo<string>();
 }
        protected override void ShouldPass()
        {
            var myThing = new MyThing();

            myThing.ShouldNotBeOfType <MyBase>();
        }
 public void ShouldPass()
 {
     var myThing = new MyThing();
     myThing.ShouldBeAssignableTo<MyBase>();
 }
Example #34
0
        public void ShouldPass()
        {
            var myThing = new MyThing();

            myThing.ShouldBeAssignableTo <MyBase>();
        }
        protected override void ShouldThrowAWobbly()
        {
            var myThing = new MyThing();

            myThing.ShouldBeAssignableTo <string>("Some additional context");
        }
Example #36
0
        protected override void ShouldPass()
        {
            var myThing = new MyThing();

            myThing.ShouldNotBeAssignableTo <string>();
        }
Example #37
0
 public void NewBasicThing()
 {
     var x = new MyThing("basic");
 }
Example #38
0
        protected override void ShouldThrowAWobbly()
        {
            var myThing = new MyThing();

            myThing.ShouldNotBeAssignableTo <MyThing>();
        }
Example #39
0
        public void ShouldPass()
        {
            MyThing myThing = null;

            myThing.ShouldBeAssignableTo <MyBase>("Some additional context");
        }
Example #40
0
 protected override void ShouldThrowAWobbly()
 {
     var myThing = new MyThing();
     myThing.ShouldNotBeAssignableTo<MyThing>();
 }
        protected override void ShouldThrowAWobbly()
        {
            var myThing = new MyThing();

            myThing.ShouldNotBeOfType <MyThing>("Some additional context");
        }
Example #42
0
 protected override void ShouldPass()
 {
     var myThing = new MyThing();
     myThing.ShouldNotBeOfType<MyBase>();
 }
 protected override void ShouldThrowAWobbly()
 {
     var myThing = new MyThing();
     myThing.ShouldNotBeAssignableTo<MyThing>("Some additional context");
 }
Example #44
0
 protected override void ShouldThrowAWobbly()
 {
     var myThing = new MyThing();
     myThing.ShouldNotBeOfType<MyThing>();
 }