Ejemplo n.º 1
0
        public DQTFileTransferStatusServiceTests()
        {
            Environment.SetEnvironmentVariable("APIKey", API_KEY);

            _loggerMock = new Mock <IRollbarService>();
            _dqtFileTransferServiceMock = new Mock <IDQTFileTransferService>();
            _mockAuth = new Mock <IAuthorize>();
            _qualifiedTeacherStatusService = new DQTFileTransferStatusService(_dqtFileTransferServiceMock.Object, _loggerMock.Object, _mockAuth.Object);
        }
        public DQTFileTransferStatusServiceTests()
        {
            Environment.SetEnvironmentVariable("APIKey", API_KEY);

            var loggerMock         = new Mock <IRollbarService>();
            var configSettingsMock = new Mock <IConfigSettings>();

            configSettingsMock.Setup(config => config.DQTApiKey).Returns(API_KEY);

            var dqtFileTransfers = new List <DQTFileTransfer>
            {
                new DQTFileTransfer()
                {
                    LastRun = today, Status = DQTFileTransferStatus.Failure.ToString(), Error = "File not found"
                },
                new DQTFileTransfer()
                {
                    LastRun = today.AddDays(-1), Status = DQTFileTransferStatus.Success.ToString(), Error = ""
                },
                new DQTFileTransfer()
                {
                    LastRun = today.AddDays(-2), Status = DQTFileTransferStatus.Failure.ToString(), Error = "File columns didn't match"
                },
                new DQTFileTransfer()
                {
                    LastRun = today.AddDays(-3), Status = DQTFileTransferStatus.Success.ToString(), Error = ""
                },
                new DQTFileTransfer()
                {
                    LastRun = today.AddDays(-4), Status = DQTFileTransferStatus.Success.ToString(), Error = ""
                }
            };

            var dbSetMock = new Mock <DbSet <DQTFileTransfer> >();

            dbSetMock.As <IQueryable <DQTFileTransfer> >().Setup(x => x.Provider).Returns(dqtFileTransfers.AsQueryable().Provider);
            dbSetMock.As <IQueryable <DQTFileTransfer> >().Setup(x => x.Expression).Returns(dqtFileTransfers.AsQueryable().Expression);
            dbSetMock.As <IQueryable <DQTFileTransfer> >().Setup(x => x.ElementType).Returns(dqtFileTransfers.AsQueryable().ElementType);
            dbSetMock.As <IQueryable <DQTFileTransfer> >().Setup(x => x.GetEnumerator()).Returns(dqtFileTransfers.AsQueryable().GetEnumerator());

            var dbContextMock = new Mock <DQTDataContext>();

            dbContextMock.Setup(x => x.Set <DQTFileTransfer>()).Returns(dbSetMock.Object);

            var repository             = new DQTFileTransferRepository(dbContextMock.Object);
            var dqtFileTransferService = new DQTFileTransferService(repository);

            _qualifiedTeacherStatusService = new DQTFileTransferStatusService(dqtFileTransferService, loggerMock.Object, new Authorize(configSettingsMock.Object));
        }