Beispiel #1
0
        public void GetStubForKey_DidNotAddStubForTheKey_ThrowsKeyNotFoundException()
        {
            var stub = new StubBuilder();

            TestDelegate invokeGetStub = () => stub.Get <double>(For.GameId);

            Assert.Throws <KeyNotFoundException>(invokeGetStub);
        }
Beispiel #2
0
        public void Out_SetupGetForId_StubsId()
        {
            const int stubbedValue = 2;
            var       foo          = new StubBuilder()
                                     .Setup <IFoo>().Get(f => f.Id).Returns(stubbedValue).Out;

            Assert.That(foo.Id, Is.EqualTo(stubbedValue));
        }
Beispiel #3
0
        public void GetStubForKey_AddedStubForTheKey_ReturnsStubbedValue()
        {
            const int stubValue = 11;
            var       stub      = new StubBuilder();

            stub.Value(For.GameId).Is(stubValue);

            Assert.That(stub.Get <int>(For.GameId), Is.EqualTo(stubValue));
        }
Beispiel #4
0
        public void OutForKey2_AddedTwoStubForDifferentKeys_ReturnsStubbedValueForKey2()
        {
            const int    stubValue1 = 11;
            const double stubValue2 = 111.0;
            var          stub       = new StubBuilder();

            stub.Value(For.GameId).Is(stubValue1);
            stub.Value(For.SB).Is(stubValue2);

            Assert.That(stub.Out <double>(For.SB), Is.EqualTo(stubValue2));
        }
Beispiel #5
0
        public void OutForKey_AddedStubForTheKeyTwice_ReturnsLastStubbedValue()
        {
            const int stubValue1 = 11;
            const int stubValue2 = 111;
            var       stub       = new StubBuilder();

            stub.Value(For.GameId).Is(stubValue1);
            stub.Value(For.GameId).Is(stubValue2);

            Assert.That(stub.Out <int>(For.GameId), Is.EqualTo(stubValue2));
        }
Beispiel #6
0
        public void GetStubForKey_TargetTypeNotEqualStubbedType_ThrowsArgumentException()
        {
            const int stubValue = 11;
            var       stub      = new StubBuilder();

            stub.Value(For.GameId).Is(stubValue);

            TestDelegate invokeGetStub = () => stub.Get <double>(For.GameId);

            Assert.Throws <ArgumentException>(invokeGetStub);
        }
Beispiel #7
0
        public void Out_SetupGetForIdAndName_StubsId()
        {
            const int    stubbedInt    = 2;
            const string stubbedString = "string";

            var foo = new StubBuilder()
                      .Setup <IFoo>().Get(f => f.Id).Returns(stubbedInt)
                      .Get(f => f.Name).Returns(stubbedString)
                      .Out;

            Assert.That(foo.Id, Is.EqualTo(stubbedInt));
        }
Beispiel #8
0
        public void OutForKey_DidNotAddStubForTheKey_ReturnsDefaultValue()
        {
            var stub = new StubBuilder();

            Assert.That(stub.Out <int>(For.GameId), Is.EqualTo(default(int)));
        }
Beispiel #9
0
        public void Out_Interface_ObjectOfTypeInterface()
        {
            var foo = new StubBuilder().Out <IFoo>();

            Assert.That(foo, Is.Not.Null);
        }
Beispiel #10
0
 internal ValueSetup(StubBuilder builder, IDictionary <For, ValueInfo> stubValues, For keyToDefine)
 {
     _builder     = builder;
     _stubValues  = stubValues;
     _keyToDefine = keyToDefine;
 }