Beispiel #1
0
        public void CallThingServiceOnce_OnFirstGet()
        {
            thingCache.Get(thingId1);

            Thing _ = null;

            A.CallTo(() => thingService.TryRead(thingId1, out _)).MustHaveHappenedOnceExactly();
        }
Beispiel #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);
        }
Beispiel #3
0
        public void Get_NoneExistingObject_ReturnsNull()
        {
            thingCache.Get(thingId1)
            .Should().BeNull();

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

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

            thingCache.Get("1").Should().BeNull();
        }
Beispiel #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();
        }
Beispiel #6
0
        public void TryRead_ExecutedOnce_AfterFirstGetSameThing()
        {
            Thing _;

            thingCache.Get(thingId1).Should().BeNull();
            A.CallTo(() => thingService.TryRead(thingId1, out _))
            .MustHaveHappened(Repeated.Exactly.Once);
        }
Beispiel #7
0
 public void TryReadFromEmptyCache_ShouldReturnNull()
 {
     thingCache.Get(thingId1)
     .Should().BeNull();
     A.CallTo(() => thingService.TryRead(thingId1, out thing1))
     .MustHaveHappenedOnceExactly();
 }
Beispiel #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);
        }
Beispiel #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();
        }
Beispiel #10
0
        public void CheckCallTryRead()
        {
            var th = thingCache.Get(thingId1);

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

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

            Assert.That(a == null);
        }