public void CallToServiceOnlyOnce() { thingCache.Get(thingId1); thingCache.Get(thingId1); A.CallTo(() => thingService.TryRead(A <string> .Ignored, out tempThing)) .MustHaveHappened(Repeated.Exactly.Once); }
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); }
public void TryReadFromEmptyCache_ShouldReturnNull() { thingCache.Get(thingId1) .Should().BeNull(); A.CallTo(() => thingService.TryRead(thingId1, out thing1)) .MustHaveHappenedOnceExactly(); }
public void CallThingServiceOnce_OnFirstGet() { thingCache.Get(thingId1); Thing _ = null; A.CallTo(() => thingService.TryRead(thingId1, out _)).MustHaveHappenedOnceExactly(); }
public void SetUp() { thingService = A.Fake <IThingService>(); A.CallTo(() => thingService.TryRead(thingId1, out thing1)).Returns(true); A.CallTo(() => thingService.TryRead(thingId2, out thing2)).Returns(true); A.CallTo(() => thingService.TryRead(thingIdNotExisted, out thing3)).Returns(false); thingCache = new ThingCache(thingService); }
public void AskThingAndReturnIt() { A.CallTo(() => thingService.TryRead(thingId1, out thing1)) .Returns(true); var actualThing = thingCache.Get(thingId1); Assert.AreEqual(thingId1, actualThing.ThingId); }
public void TestCanReadShouldCallOnlyOnce() { var firstItem = cache.Get(thingKey2); var secondItem = cache.Get(thingKey2); Assert.That(firstItem == secondItem); Assert.That(firstItem == thing2); A.CallTo(() => service.TryRead(thingKey2, out thing2)).MustHaveHappenedOnceExactly(); A.CallTo(() => service.TryRead(A <string> .Ignored, out thing2)).MustHaveHappenedOnceExactly(); }
public void Configure() { service = A.Fake <IThingService>(); cache = new ThingCache(service); A.CallTo(() => service.TryRead(A <string> .Ignored, out thing1)).Returns(false); A.CallTo(() => service.TryRead(thingKey1, out thing1)) .Returns(true); A.CallTo(() => service.TryRead(thingKey2, out thing2)) .Returns(true); }
public void ReturnsNull_WhenIdNotExists() { Thing thing; A.CallTo(() => thingService.TryRead("1", out thing)).Returns(false); thingCache.Get("1").Should().BeNull(); }
public void SetUp() { thingService = A.Fake <IThingService>(); thingCache = new ThingCache(thingService); Thing thing; A.CallTo(() => thingService.TryRead(A <string> .Ignored, out thing)).Returns(false); A.CallTo(() => thingService.TryRead(thingId1, out thing)).Returns(true) .AssignsOutAndRefParameters(thing1); A.CallTo(() => thingService.TryRead(thingId2, out thing)).Returns(true) .AssignsOutAndRefParameters(thing2);; }
public void Get_NoneExistingObject_ReturnsNull() { thingCache.Get(thingId1) .Should().BeNull(); A.CallTo(() => thingService.TryRead(thingId1, out thing1)) .MustHaveHappened(); }
public void SetUp() { thingService = A.Fake <IThingService>(); thingCache = new ThingCache(thingService); Thing _ = null; A.CallTo(() => thingService.TryRead(thingId1, out _)) .Returns(true) .AssignsOutAndRefParameters(thing1); A.CallTo(() => thingService.TryRead(thingId2, out _)) .Returns(true) .AssignsOutAndRefParameters(thing2); }
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(); }
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); }
public Thing Get(string thingId) { if (dictionary.TryGetValue(thingId, out var thing)) { return(thing); } if (thingService.TryRead(thingId, out thing)) { dictionary[thingId] = thing; return(thing); } return(null); }
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(); }
public void CheckCallTryRead() { var th = thingCache.Get(thingId1); A.CallTo(() => thingService.TryRead(thingId1, out thing1)).WithAnyArguments().MustHaveHappenedOnceExactly(); }
public void Cache_Should_CallService_When_NoKeyFoundInside() { thingCache.Get(thingId1); A.CallTo(() => thingService.TryRead(thingId1, out thing1)).MustHaveHappened(); }
public void TryRead_ExecutedOnce_AfterFirstGetSameThing() { Thing _; thingCache.Get(thingId1).Should().BeNull(); A.CallTo(() => thingService.TryRead(thingId1, out _)) .MustHaveHappened(Repeated.Exactly.Once); }
public void ThingCache_Get_MethodCallingHappened() { thingCache.Get(thingId1); A.CallTo(() => thingService.TryRead(thingId1, out thing1)).MustHaveHappenedOnceExactly(); }