Пример #1
0
 public DummyContext(string folder, DaoMethodCallsCounter methodCallerCounter = null) : base("db1", new Dictionary <string, object>
 {
     ["folder"]  = folder,
     ["counter"] = methodCallerCounter
 })
 {
 }
        public void TestQueryNoSuchMethod()
        {
            // Arrange
            var methodCounter = new DaoMethodCallsCounter();
            var context       = new DummyContext(_folder, methodCounter);

            // Act
            var result = context.DummyEntitiesWithCache.Query <bool>("NoSuchMethod");

            // Assert
            Assert.IsTrue(result);
        }
        public void TestSavesUpdatedEntitiesAndReturnsThemInQueryNonCached()
        {
            // Arrange
            var methodCounter = new DaoMethodCallsCounter();
            var context       = new DummyContext(_folder, methodCounter);

            var itemToAdd = new DummyEntity
            {
                Key  = "4000",
                Name = "Item 4000"
            };

            context.DummyEntitiesWithCache.Add(itemToAdd);

            // Ensure item do not exist

            var result = context.DummyEntitiesWithCache.Where(x => x.Key == "4000").FirstOrDefault();

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual("Item 4000", result.Name);
            //Assert.AreEqual(1000, methodCounter.EntityCallsCount); // 1000 calls for cannot get id from invocations
        }
Пример #4
0
 public void SetProperties(IReadOnlyDictionary <string, object> properties)
 {
     _folder = (string)properties["folder"];
     properties.TryGetValue("counter", out var methodCounter);
     _methodCallerCounter = (DaoMethodCallsCounter)methodCounter;
 }