Esempio n. 1
0
        /// <summary>
        /// Creates a mockup for the data provider which uses MySQL.
        /// </summary>
        /// <returns>Mockup for the data provider which uses MySQL.</returns>
        private IMySqlDataProvider CreateMySqlDataProvider(ISystemProxy systemProxy = null, IEnumerable <BrugeraftaleProxy> appointmentUserCollection = null)
        {
            IMySqlDataProvider dataProviderMock = MockRepository.GenerateMock <IMySqlDataProvider>();

            dataProviderMock.Stub(m => m.Clone())
            .Return(dataProviderMock)
            .Repeat.Any();
            dataProviderMock.Stub(m => m.Create(Arg <ISystemProxy> .Is.TypeOf, Arg <MySqlDataReader> .Is.Anything, Arg <string[]> .Is.Anything))
            .Return(systemProxy ?? MockRepository.GenerateMock <ISystemProxy>())
            .Repeat.Any();
            dataProviderMock.Stub(m => m.GetCollection <BrugeraftaleProxy>(Arg <MySqlCommand> .Is.Anything))
            .Return(appointmentUserCollection ?? _fixture.CreateMany <BrugeraftaleProxy>(_random.Next(3, 7)).ToList())
            .Repeat.Any();
            return(dataProviderMock);
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a mockup for the data provider which uses MySQL.
        /// </summary>
        /// <returns>Mockup for the data provider which uses MySQL.</returns>
        private IMySqlDataProvider CreateMySqlDataProvider(ISystemProxy systemProxy = null, IAftaleProxy appointmentProxy = null, IBrugerProxy calenderUserProxy = null)
        {
            IMySqlDataProvider dataProviderMock = MockRepository.GenerateMock <IMySqlDataProvider>();

            dataProviderMock.Stub(m => m.Create(Arg <ISystemProxy> .Is.TypeOf, Arg <MySqlDataReader> .Is.Anything, Arg <string[]> .Is.Anything))
            .Return(systemProxy ?? MockRepository.GenerateMock <ISystemProxy>())
            .Repeat.Any();
            dataProviderMock.Stub(m => m.Create(Arg <IAftaleProxy> .Is.TypeOf, Arg <MySqlDataReader> .Is.Anything, Arg <string[]> .Is.Anything))
            .Return(appointmentProxy ?? MockRepository.GenerateMock <IAftaleProxy>())
            .Repeat.Any();
            dataProviderMock.Stub(m => m.Create(Arg <IBrugerProxy> .Is.TypeOf, Arg <MySqlDataReader> .Is.Anything, Arg <string[]> .Is.Anything))
            .Return(calenderUserProxy ?? MockRepository.GenerateMock <IBrugerProxy>())
            .Repeat.Any();
            return(dataProviderMock);
        }
        /// <summary>
        /// Creates a mockup for the data provider which uses MySQL.
        /// </summary>
        /// <returns>Mockup for the data provider which uses MySQL.</returns>
        private IMySqlDataProvider CreateMySqlDataProvider(ISystemProxy systemProxy = null)
        {
            IMySqlDataProvider dataProviderMock = MockRepository.GenerateMock <IMySqlDataProvider>();

            dataProviderMock.Stub(m => m.Create(Arg <ISystemProxy> .Is.TypeOf, Arg <MySqlDataReader> .Is.Anything, Arg <string[]> .Is.Anything))
            .Return(systemProxy ?? MockRepository.GenerateMock <ISystemProxy>())
            .Repeat.Any();
            return(dataProviderMock);
        }
        /// <summary>
        /// Creates a mockup for the data provider which uses MySQL.
        /// </summary>
        /// <returns>Mockup for the data provider which uses MySQL.</returns>
        private IMySqlDataProvider CreateMySqlDataProvider(IEnumerable <SystemProxy> systemProxyCollection = null, Exception exception = null)
        {
            IMySqlDataProvider mySqlDataProviderMock = MockRepository.GenerateMock <IMySqlDataProvider>();

            if (exception == null)
            {
                mySqlDataProviderMock.Stub(m => m.GetCollection <SystemProxy>(Arg <MySqlCommand> .Is.Anything))
                .Return(systemProxyCollection ?? _fixture.CreateMany <SystemProxy>(_random.Next(5, 10)).ToList())
                .Repeat.Any();
            }
            else
            {
                mySqlDataProviderMock.Stub(m => m.GetCollection <SystemProxy>(Arg <MySqlCommand> .Is.Anything))
                .Throw(exception)
                .Repeat.Any();
            }
            return(mySqlDataProviderMock);
        }
Esempio n. 5
0
        /// <summary>
        /// Creates an instance of the calender repository which can be used for unit testing.
        /// </summary>
        /// <returns>Instance of the calender repository which can be used for unit testing.</returns>
        private IKalenderRepository CreateSut(IEnumerable <AftaleProxy> appointmentProxyCollection = null, AftaleProxy appointmentProxy = null, IEnumerable <BrugerProxy> calenderUserProxyCollection = null, Exception exception = null)
        {
            if (exception == null)
            {
                _dataProviderMock.Stub(m => m.GetCollection <AftaleProxy>(Arg <MySqlCommand> .Is.Anything))
                .Return(appointmentProxyCollection ?? _fixture.Build <AftaleProxy>().With(m => m.FraTidspunkt, DateTime.MinValue).With(m => m.TilTidspunkt, DateTime.MaxValue).CreateMany(_random.Next(15, 25)).ToList())
                .Repeat.Any();
            }
            else
            {
                _dataProviderMock.Stub(m => m.GetCollection <AftaleProxy>(Arg <MySqlCommand> .Is.Anything))
                .Throw(exception)
                .Repeat.Any();
            }

            if (exception == null)
            {
                _dataProviderMock.Stub(m => m.Get(Arg <AftaleProxy> .Is.Anything))
                .Return(appointmentProxy ?? _fixture.Build <AftaleProxy>().With(m => m.FraTidspunkt, DateTime.MinValue).With(m => m.TilTidspunkt, DateTime.MaxValue).Create())
                .Repeat.Any();
            }
            else
            {
                _dataProviderMock.Stub(m => m.Get(Arg <AftaleProxy> .Is.Anything))
                .Throw(exception)
                .Repeat.Any();
            }

            if (exception == null)
            {
                _dataProviderMock.Stub(m => m.GetCollection <BrugerProxy>(Arg <MySqlCommand> .Is.Anything))
                .Return(calenderUserProxyCollection ?? _fixture.CreateMany <BrugerProxy>(_random.Next(3, 10)).ToList())
                .Repeat.Any();
            }
            else
            {
                _dataProviderMock.Stub(m => m.GetCollection <BrugerProxy>(Arg <MySqlCommand> .Is.Anything))
                .Throw(exception)
                .Repeat.Any();
            }

            return(new KalenderRepository(_dataProviderMock));
        }