Esempio n. 1
0
        public void CallThingServiceOnce_OnFirstGet()
        {
            thingCache.Get(thingId1);

            Thing _ = null;

            A.CallTo(() => thingService.TryRead(thingId1, out _)).MustHaveHappenedOnceExactly();
        }
Esempio n. 2
0
        public void TryGetExistedElement()
        {
            var value = new Thing(thingId1);

            A.CallTo(() => thingService.TryRead(thingId1, out value))
            .Returns(true);

            var actual = thingCache.Get(thingId1);

            actual.Should().Be(value);
        }
Esempio n. 3
0
        public void Get_NoneExistingObject_ReturnsNull()
        {
            thingCache.Get(thingId1)
            .Should().BeNull();

            A.CallTo(() => thingService.TryRead(thingId1, out thing1))
            .MustHaveHappened();
        }
Esempio n. 4
0
        public void ReturnsNull_WhenIdNotExists()
        {
            Thing thing;

            A.CallTo(() => thingService.TryRead("1", out thing)).Returns(false);

            thingCache.Get("1").Should().BeNull();
        }
Esempio n. 5
0
        public void SingleThingGetting()
        {
            A.CallTo(() => thingService.TryRead(thingId1, out thing1)).Returns(true);
            Assert.AreEqual(thing1, thingCache.Get(thingId1));

            Thing value;

            A.CallTo(() => thingService.TryRead(A <string> .Ignored, out value)).MustHaveHappened();
        }
Esempio n. 6
0
        public void TryRead_ExecutedOnce_AfterFirstGetSameThing()
        {
            Thing _;

            thingCache.Get(thingId1).Should().BeNull();
            A.CallTo(() => thingService.TryRead(thingId1, out _))
            .MustHaveHappened(Repeated.Exactly.Once);
        }
Esempio n. 7
0
 public void TryReadFromEmptyCache_ShouldReturnNull()
 {
     thingCache.Get(thingId1)
     .Should().BeNull();
     A.CallTo(() => thingService.TryRead(thingId1, out thing1))
     .MustHaveHappenedOnceExactly();
 }
Esempio n. 8
0
        public void Get_CallsService_WhenCalledOneTime()
        {
            var th1 = thingCache.Get(thingId1);

            A.CallTo(() => thingService.TryRead(thingId1, out th1)).MustHaveHappened(1, Times.Exactly);
            th1.Should().Be(thing1);
        }
Esempio n. 9
0
        public void ReturnCorrectThing_TakeItFirstTimeFromService()
        {
            A.CallTo(() => thingService.TryRead(thingId1, out thing1)).Returns(true);

            thingCache.Get(thingId1).Should().Be(thing1);
            A.CallTo(() => thingService.TryRead(thingId1, out thing1)).MustHaveHappened();
        }
Esempio n. 10
0
        public void CheckCallTryRead()
        {
            var th = thingCache.Get(thingId1);

            A.CallTo(() => thingService.TryRead(thingId1, out thing1)).WithAnyArguments().MustHaveHappenedOnceExactly();
        }
Esempio n. 11
0
 public void Cache_Should_CallService_When_NoKeyFoundInside()
 {
     thingCache.Get(thingId1);
     A.CallTo(() => thingService.TryRead(thingId1, out thing1)).MustHaveHappened();
 }
Esempio n. 12
0
        public void ThingCache_Get_ReturnsCorrectValue()
        {
            var actualValue = thingCache.Get(thingId1);

            Assert.That(actualValue, Is.EqualTo(thing1));
        }
Esempio n. 13
0
 public void CallToServiceOnlyOnce()
 {
     thingCache.Get(thingId1);
     thingCache.Get(thingId1);
     A.CallTo(() => thingService.TryRead(A <string> .Ignored, out tempThing))
     .MustHaveHappened(Repeated.Exactly.Once);
 }
Esempio n. 14
0
        public void TestGetUnregisteredKey()
        {
            var a = cache.Get("test_tmp");

            Assert.That(a == null);
        }