public void Parse_WhenInCache_ShouldNotAdd() { var parser = new Mock <IActivityParser>(); parser.Setup(a => a.Parse(It.IsAny <DynamicActivity>())).Returns(new Mock <IDev2Activity>().Object); var resourceActivityCache = new ResourceActivityCache(parser.Object, new System.Collections.Concurrent.ConcurrentDictionary <Guid, Dev2.IDev2Activity>()); var resourceId = Guid.NewGuid(); resourceActivityCache.Parse(new DynamicActivity(), resourceId); Assert.IsNotNull(resourceActivityCache); Assert.AreEqual(1, resourceActivityCache.Cache.Count); Assert.IsTrue(resourceActivityCache.Cache.ContainsKey(resourceId)); resourceActivityCache.Parse(new DynamicActivity(), resourceId); Assert.AreEqual(1, resourceActivityCache.Cache.Count); Assert.IsTrue(resourceActivityCache.Cache.ContainsKey(resourceId)); }
public void HasInCache_WhenNotInCache_ShouldReturnFalse() { var parser = new Mock <IActivityParser>(); parser.Setup(a => a.Parse(It.IsAny <DynamicActivity>())).Returns(new Mock <IDev2Activity>().Object); var resourceActivityCache = new ResourceActivityCache(parser.Object, new System.Collections.Concurrent.ConcurrentDictionary <Guid, Dev2.IDev2Activity>()); var resourceId = Guid.NewGuid(); resourceActivityCache.Parse(new DynamicActivity(), resourceId); Assert.IsFalse(resourceActivityCache.HasActivityInCache(Guid.NewGuid())); }