Exemplo n.º 1
0
        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;
        }
Exemplo n.º 2
0
 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);
 }
Exemplo n.º 3
0
 public void SetUp()
 {
     storage = new DbCollectionMockStorage();
     dbCollectionMock = MockProvider.GetDBCollectionMock(storage);
 }
Exemplo n.º 4
0
 public void SetUp()
 {
     processors = new DbCollectionMockStorage();
     processorCollectionMock = MockProvider.GetDBCollectionMock(processors);
     rams = new DbCollectionMockStorage();
     ramCollectionMock = MockProvider.GetDBCollectionMock(rams);
     aggregatorProviderMock = new Mock<IAggregatorProvider>(MockBehavior.Loose);
 }
Exemplo n.º 5
0
 public void SetUp()
 {
     processors = new DbCollectionMockStorage();
     processorCollectionMock = MockProvider.GetDBCollectionMock(processors);
     rams = new DbCollectionMockStorage();
     ramCollectionMock = MockProvider.GetDBCollectionMock(rams);
     aggregatorProviderMock = MockProvider.GetAggregatorProviderMock();
 }