Beispiel #1
0
        public void CreateTopic_NoRead_CorrectError()
        {
            var reader = _mocks.DynamicMock<IDnaDataReader>();
            reader.Stub(x => x.Read()).Return(false);
            reader.Stub(x => x.GetInt32NullAsZero("topicid")).Return(1);
            reader.Stub(x => x.GetInt32NullAsZero("TopicElementID")).Return(1);
            reader.Stub(x => x.GetInt32NullAsZero("ValidID")).Return(1);

            var creator = _mocks.DynamicMock<IDnaDataReaderCreator>();
            creator.Stub(x => x.CreateDnaDataReader("createtopic")).Return(reader);
            creator.Stub(x => x.CreateDnaDataReader("createtopicelement")).Return(reader);
            creator.Stub(x => x.CreateDnaDataReader("updatetopicelement")).Return(reader);


            _mocks.ReplayAll();

            var actual = new TopicElement();
            var result = actual.CreateTopic(creator, 0, 0);
            Assert.AreEqual(0, actual.TopicId);
            Assert.AreEqual("CreateTopic", result.Type);
            Assert.AreEqual("Error", result.GetType().Name);

        }
Beispiel #2
0
        public void CreateTopic_ValidRecordset_CorrectTopic()
        {
            var reader = _mocks.DynamicMock<IDnaDataReader>();
            reader.Stub(x => x.Read()).Return(true);
            reader.Stub(x => x.GetInt32NullAsZero("itopicid")).Return(1);
            reader.Stub(x => x.GetInt32NullAsZero("TopicElementID")).Return(1);
            reader.Stub(x => x.GetInt32NullAsZero("ValidID")).Return(1);

            var creator = _mocks.DynamicMock<IDnaDataReaderCreator>();
            creator.Stub(x => x.CreateDnaDataReader("createtopic")).Return(reader);
            creator.Stub(x => x.CreateDnaDataReader("createtopicelement")).Return(reader);
            creator.Stub(x => x.CreateDnaDataReader("updatetopicelement")).Return(reader);
            
            
            _mocks.ReplayAll();

            var actual = new TopicElement();
            var result = actual.CreateTopic(creator, 0, 0);
            Assert.AreEqual(1, actual.TopicId);
            Assert.AreEqual("UpdateFrontPageElements", result.Type);
            Assert.AreEqual("Result", result.GetType().Name);

        }