public static Mock<IDBCollection> GetDBCollectionMock(DbCollectionMockStorage storage) { var dBCollectionMock = new Mock<IDBCollection>(MockBehavior.Strict); dBCollectionMock.Setup(x => x.GetModelField(It.IsAny<Id>(), It.IsAny<string>())) .Returns((Id id, string fieldName) => storage[id][fieldName]); dBCollectionMock.Setup(x => x.UpdateFields(It.IsAny<Id>(), It.IsNotNull<IDictionary<string, object>>())) .Callback((Id id, IDictionary<string, object> fieldVals) => storage[id].Update(fieldVals)); dBCollectionMock.Setup(x => x.GetFields(It.IsAny<Id>(), It.IsNotNull<string[]>())) .Returns((Id id, string[] fieldNames) => fieldNames.ToDictionary(x => x, x => storage[id][x])); dBCollectionMock.Setup(x => x.ArrayElem(It.IsNotNull<Id>(), It.IsNotNull<string>(), It.IsAny<int>())) .Returns((Id id, string name, int i) => ((IEnumerable)(storage[id][name])).Cast<object>().ElementAt(i)); return dBCollectionMock; }
public void SetUp() { storage = new DbCollectionMockStorage(); dbCollectionMock = MockProvider.GetDBCollectionMock(storage); dbMock = new Mock<IDB>(); dbMock.Setup(x => x.GetCollection(It.Is<string>(y => y.Equals("Foos")))) .Returns(dbCollectionMock.Object); }
public void SetUp() { storage = new DbCollectionMockStorage(); dbCollectionMock = MockProvider.GetDBCollectionMock(storage); }
public void SetUp() { processors = new DbCollectionMockStorage(); processorCollectionMock = MockProvider.GetDBCollectionMock(processors); rams = new DbCollectionMockStorage(); ramCollectionMock = MockProvider.GetDBCollectionMock(rams); aggregatorProviderMock = new Mock<IAggregatorProvider>(MockBehavior.Loose); }
public void SetUp() { processors = new DbCollectionMockStorage(); processorCollectionMock = MockProvider.GetDBCollectionMock(processors); rams = new DbCollectionMockStorage(); ramCollectionMock = MockProvider.GetDBCollectionMock(rams); aggregatorProviderMock = MockProvider.GetAggregatorProviderMock(); }