Esempio n. 1
0
        public async Task Db_ErrorsReportingService_GetApplicationAsync()
        {
            using (IUnityContainer childContainer = this.container.CreateChildContainer())
            {
                IErrorsReportingService service     = childContainer.Resolve <IErrorsReportingService>();
                ErrorReportApplication  application = await service.GetApplicationAsync("TestApplicationAlreadyExisting", "a.a.a.a");

                Assert.Greater(application.Id, 0);
                Assert.AreEqual(new DateTime(2000, 1, 1), application.FirstRunDate);
            }
        }
Esempio n. 2
0
        public void Db_ErrorsReportingService_GetApplicationAsync_NotExisting()
        {
            using (IUnityContainer childContainer = this.container.CreateChildContainer())
            {
                IErrorsReportingService service     = childContainer.Resolve <IErrorsReportingService>();
                ErrorReportApplication  application = null;
                Assert.That(async() =>
                {
                    application = await service.GetApplicationAsync("TestApplicationAlreadyExisting", "z.z.z.z");
                }, Throws.Nothing);

                Assert.IsNull(application);
            }
        }
Esempio n. 3
0
        public async Task GetApplicationAsync()
        {
            VolatileErrorsReportingDataset store = new VolatileErrorsReportingDataset();

            Mock <IErrorsReportingService> mockService = new Mock <IErrorsReportingService>();

            mockService.Setup(s => s.GetApplicationAsync(It.IsAny <string>(), It.IsAny <string>()))
            .Returns <string, string>((name, version) =>
                                      Task.FromResult <ErrorReportApplication>(store.Applications.Single(a => a.Name == name && a.Version == version)));

            IErrorsReportingService service     = mockService.Object;
            ErrorReportApplication  application = await service.GetApplicationAsync("TestApplicationAlreadyExisting", "1.0.0.0");

            Assert.AreEqual(1, application.Id);
            Assert.AreEqual(new DateTime(2000, 1, 1), application.FirstRunDate);
        }
Esempio n. 4
0
        public void GetApplicationAsync_NotExisting()
        {
            VolatileErrorsReportingDataset store = new VolatileErrorsReportingDataset();

            Mock <IErrorsReportingService> mockService = new Mock <IErrorsReportingService>();

            mockService.Setup(s => s.GetApplicationAsync(It.IsNotIn <string>(store.Applications.Select(a => a.Name)), It.IsAny <string>()))
            .Returns <string, string>((name, version) =>
                                      Task.FromResult <ErrorReportApplication>(null));

            IErrorsReportingService service = mockService.Object;

            ErrorReportApplication application = null;

            Assert.That(async() =>
            {
                application = await service.GetApplicationAsync("TestApplicationNotExisting", "1.0.0.0");
            }, Throws.Nothing);

            Assert.IsNull(application);
        }