Ejemplo n.º 1
0
        public void initialize()
        {
            //initialixe serves as the composition root
            //guid = Guid.NewGuid();
            LogId = 5;
            _logRepository = A.Fake<ILogLvsRepository>();
            A.CallTo(() => _logRepository.GetByID(LogId))
                .Returns(new Logqso.mvc.DataModel.LogData.DataModels.Log
                {
                    LogId = LogId,
                    ContestYear = DateTime.Now,
                    ContestId = "CQWWSSB2002",
                });

            //Badguid = Guid.NewGuid();
            badLogId = -1;
            A.CallTo(() => _logRepository.GetByID(badLogId))
               .Returns(null);
            //.Throws<LogNotFoundException>();
            //.Throws(new LogNotFoundException("hello"));

            A.CallTo(() => _logRepository.GetByYear(Year))
                .Returns(new List<Logqso.mvc.DataModel.LogData.DataModels.Log> {
                new Logqso.mvc.DataModel.LogData.DataModels.Log() {LogId = 1,  ContestId = "CQWWSSB2002" , ContestYear = Year    },
                new Logqso.mvc.DataModel.LogData.DataModels.Log() {LogId = 2,  ContestId = "CQWWSSB2002" , ContestYear = Year    },
                } );



            //automapper
            AutoMapper.Mapper.CreateMap<Logqso.mvc.DataModel.LogData.DataModels.Log,  Logqso.mvc.Entities.LogDataEntity.Log>();

            _logService = new LogLvsService(_logRepository);
        }
Ejemplo n.º 2
0
        public void Unit_LogService_Log_ValidLogCallsignID_ReturnmLog()
        {
            //var log = new Log();
            //Guid guid = Guid.NewGuid();
            //log.FindByID(guid);  //need to call this first, ordered dependence!
            //Assert.IsInstanceOfType(log.LogCallsignID, typeof(Guid));
            //Assert.IsInstanceOfType(log.ContestYear, typeof(DateTime));
            //Assert.AreEqual(log.ContestYear.Year, DateTime.Now.Year);

            //Fake eliminates next 3 lines
#if nofake 
           Guid guid = Guid.NewGuid();
           var LogRepository = new LogRepository();
           var logService = new LogService(LogRepository);
#else
           var logService = new LogLvsService(_logRepository);
#endif

           Logqso.mvc.Entities.LogDataEntity.Log  LogEntity = logService.GetByID(LogId);
           Assert.IsInstanceOfType(LogEntity, typeof( Logqso.mvc.Entities.LogDataEntity.Log));
           Assert.AreEqual(  LogId, LogEntity.LogId);
           Assert.IsInstanceOfType(LogEntity.ContestYear, typeof(DateTime));
           Assert.AreEqual( DateTime.Now.Year, LogEntity.ContestYear.Year);

        }
Ejemplo n.º 3
0
        public void initialize()
        {
            //initialixe serves as the composition root
            //guid = Guid.NewGuid();
            LogId = 5;
            _logRepository = A.Fake<ILogLvsRepository>();
            A.CallTo(() => _logRepository.GetByID(LogId))
                .Returns(new Logqso.mvc.DataModel.LogData.DataModels.Log
                {
                    LogId = LogId,
                    ContestYear = DateTime.Now,
                    ContestId = "CQWWSSB2002",
                });

            //Badguid = Guid.NewGuid();
            badLogId = -1;
            A.CallTo(() => _logRepository.GetByID(badLogId))
               .Returns(null);
            //.Throws<LogNotFoundException>();
            //.Throws(new LogNotFoundException("hello"));

#if true
            _QsoRepository = A.Fake<IQsoRepository>();
            A.CallTo(() => _QsoRepository.CreateQso(LogId))
                .Returns(new Logqso.mvc.DataModel.LogData.DataModels.Qso
                    {
                        LogId = LogId,
                        CallsignId = 2,
                        QsoNo = 1,
                        QsoDateTime = DateTime.Now,
                        RxRst = 59,
                        TxRst = 59,

                    });
#else
            _QsoRepository = new QsoRepository();

#endif


            //automapper
            AutoMapper.Mapper.CreateMap<Logqso.mvc.DataModel.LogData.DataModels.Log, Logqso.mvc.Entities.LogDataEntity.Log>();
            _logService = new LogLvsService(_logRepository);

            AutoMapper.Mapper.CreateMap<Logqso.mvc.DataModel.LogData.DataModels.Qso, Qso>();
            _qsoService = new QsoService(_QsoRepository);

        }