public void TestFindCollection()
        {
            var mapperDictionary = new MapperDictionary();
            var fakeSearchCriteria = new Mock<IPersistenceCollectionSearcher<FakeObject>>();
            var mapper = new Mock<IStoredProcedureMapper<FakeObject>>();
            var fakeCollection = new Queue<FakeObject>();
            var fakeObject1 = new FakeObject();
            var fakeObject2 = new FakeObject();
            var fakeConnection = new Mock<IDbConnection>();

            fakeCollection.Enqueue(fakeObject1);
            fakeCollection.Enqueue(fakeObject2);

            var fakeReader = new Mock<IDataReader>();
            fakeReader.Setup(r => r.Read())
                .Returns(new Queue<bool>(new[] { true, true, false }).Dequeue);

            var fakeCommand = new Mock<IDbCommand>();
            fakeCommand.Setup(c => c.ExecuteReader()).Returns(fakeReader.Object);

            mapper.Setup(m => m.GetSelectCommand(fakeSearchCriteria.Object)).Returns(fakeCommand.Object);
            mapper.Setup(m => m.PopulateObject(fakeReader.Object)).Returns(fakeCollection.Dequeue);

            mapperDictionary.Add(typeof(FakeObject), mapper.Object.GetType());

            var actual = new StoredProcedureMappingContext(fakeConnection.Object, mapperDictionary).Find<FakeObject>(fakeSearchCriteria.Object);

            Assert.AreEqual(fakeObject1, actual.ElementAt(0));
            Assert.AreEqual(fakeObject2, actual.ElementAt(1));
        }
        public void TestChange()
        {
            var mapperDictionary = new MapperDictionary();
            var mapper = new Mock<IStoredProcedureMapper<FakeObject>>();
            var command = new Mock<IDbCommand>();
            var fakeObject = new FakeObject();
            var fakeConnection = new Mock<IDbConnection>();

            mapper.Setup(m => m.GetUpdateCommand(fakeObject)).Returns(command.Object);
            mapperDictionary.Add(typeof(FakeObject), mapper.Object.GetType());

            var context = new StoredProcedureMappingContext(fakeConnection.Object, mapperDictionary);
            context.Change(fakeObject);
        }
        public void TestFindSingleObject()
        {
            var mapperDictionary = new MapperDictionary();
            var fakeSearchCriteria = new Mock<IPersistenceSearcher<FakeObject>>();
            var mapper = new Mock<IStoredProcedureMapper<FakeObject>>();
            var fakeConnection = new Mock<IDbConnection>();
            var fakeObject = new FakeObject();
            var fakeReader = new Mock<IDataReader>();
            var readToggle = true;
            fakeReader.Setup(x => x.Read())
                .Returns(() => readToggle)
                .Callback(() => readToggle = false);

            var command = new Mock<IDbCommand>();
            command.Setup(c => c.ExecuteReader(CommandBehavior.SingleRow)).Returns(fakeReader.Object);

            mapper.Setup(m => m.GetSelectCommand(fakeSearchCriteria.Object)).Returns(command.Object);
            mapper.Setup(m => m.PopulateObject(fakeReader.Object)).Returns(fakeObject);
            mapperDictionary.Add(typeof(FakeObject), mapper.Object.GetType());

            var actual = new StoredProcedureMappingContext(fakeConnection.Object, mapperDictionary).Find<FakeObject>(fakeSearchCriteria.Object);

            Assert.AreEqual(fakeObject, actual);
        }
 public void TestDictionary()
 {
     var dictionary = new MapperDictionary();
     dictionary.Add<FakeObject, IStoredProcedureMapper<FakeObject>>();
 }