public async Task GetNameTwiceWhenContactExistsShouldUseCachedValue() { // Arrange using (OwnerContext.Create(Application.Identity)) { Configuration.ContactCacheEnabled.Returns(true); Configuration.ContactCacheExpiration.Returns(TimeSpan.FromMinutes(5)); var target = GetTarget(); // Act var actualName = await target.GetVariableAsync("name", Context, CancellationToken); var actualAddress = await target.GetVariableAsync("address", Context, CancellationToken); // Asset actualName.ShouldBe(Contact.Name); actualAddress.ShouldBe(Contact.Address); ContactExtension.Received(1).GetAsync(Arg.Any <Identity>(), Arg.Any <CancellationToken>()); var cachedContact = await OwnerCallerContactMap.GetValueOrDefaultAsync(OwnerCaller.Create(Application.Identity, Contact.Identity)); cachedContact.ShouldNotBeNull(); } }
private static OwnerCaller CreateKey(Identity identity) => OwnerCaller.Create(OwnerContext.Owner, identity);
private OwnerCaller CreateKey(Application applicationSettings, Identity identity) => OwnerCaller.Create(GetApplicationIdentity(applicationSettings), identity);