public void Given()
 {
     _container          = RestApiApplication.CreateContainer();
     _gitt               = new Gitt(_container);
     _dataContextFactory = _container.Resolve <DataContextFactory>();
     TimeService.ResetToRealTime();
 }
        public void EnsureDatabase()
        {
            //AppDomain.CurrentDomain.SetData("DataDirectory", Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ""));

            using (var context = RestApiApplication.CreateContainer().Resolve <DataContextFactory>().Create())
            {
                var triggerCreateDatabase = context.Lag.Any();
            }
        }
示例#3
0
        public void EnsureDatabase()
        {
            _container = RestApiApplication.CreateContainer();

            SetConnectionStringFromEnvironmentVariable();

            using (var context = _container.Resolve <DataContextFactory>().Create())
            {
                var triggerCreateDatabase = context.Lag.Any();
            }
        }
示例#4
0
        public void Given()
        {
            _container = RestApiApplication.CreateContainer();

            _dataContextFactory = _container.Resolve <DataContextFactory>();

            _dataContextFactory.DeleteAllData();

            TimeService.ResetToRealTime();
            _excelWriter = new ExcelWriter();
        }
示例#5
0
        public void Given()
        {
            _container          = RestApiApplication.CreateContainer();
            _gitt               = new Gitt(_container);
            _dataContextFactory = _container.Resolve <DataContextFactory>();
            TimeService.ResetToRealTime();

            // Slett alle meldinger (blir rullet tilbake i transaksjon uansett)
            using (var context = _dataContextFactory.Create())
            {
                context.Meldinger.Clear();
                context.SaveChanges();
            }
        }
        public async void ImportFrom_GoogleDocs()
        {
            var excelImport = RestApiApplication.CreateContainer().Resolve <Repository.Import.ExcelImport>();

            var downloader = new GoogleDriveDownloader();

            var documentId = Environment.GetEnvironmentVariable("BBR_GoogleDocId", EnvironmentVariableTarget.User);

            if (string.IsNullOrEmpty(documentId))
            {
                Assert.Fail("Cannot import if documentId is not set in environment variable");
            }

            var content = await downloader.LastNedSpreadsheetFraGoogleDrive(documentId);

            excelImport.LesInn(content);
        }
        public void Given()
        {
            _container = RestApiApplication.CreateContainer();

            _appSettings = new OverridableSettings();
            _container.Register(Component.For <OverridableSettings>().Instance(_appSettings).IsDefault().Named(Guid.NewGuid().ToString()));

            _gitt = new Gitt(_container);
            _dataContextFactory = _container.Resolve <DataContextFactory>();
            TimeService.ResetToRealTime();

            // Slett alle posisjoner (blir rullet tilbake i transaksjon uansett)
            using (var context = _dataContextFactory.Create())
            {
                context.DeltakerPosisjoner.Clear();
                context.SaveChanges();
            }
        }
示例#8
0
        public void Export()
        {
            _container = RestApiApplication.CreateContainer();

            var hardcodedMatchProvider = new HardcodedMatchProvider(null);

            hardcodedMatchProvider.SetMatchId(new Guid("4A82121D-71A6-45AE-AFD8-41574086B55C"));

            _container.Register(
                Component.For <CurrentMatchProvider>()
                .Instance(hardcodedMatchProvider)
                .Named(Guid.NewGuid().ToString())
                .IsDefault());

            var service = _container.Resolve <KmlExport>();

            var kml = service.GetKml();

            File.WriteAllText(@"c:\temp\bbr2015.kml", kml);

            Assert.IsNotNullOrEmpty(kml);
        }
        public void NårApplikasjonenRestartes_SkalSistePosisjonerHentesFraDatabasen()
        {
            var givenLag = _gitt.ToLagMedToDeltakere();

            var posisjonsSevice = _container.Resolve <PosisjonsService>();

            var latitude  = 59.6785526164;
            var longitude = 10.6039274298;

            foreach (var lag in givenLag)
            {
                foreach (var deltaker in lag.Deltakere)
                {
                    posisjonsSevice.RegistrerPosisjon(deltaker.Lag.LagId, deltaker.DeltakerId, latitude, longitude);
                    TimeService.AddSeconds(200);
                    posisjonsSevice.RegistrerPosisjon(deltaker.Lag.LagId, deltaker.DeltakerId, latitude + 5, longitude + 5);
                }
            }


            // Lag ny container for å simulere restart
            _container = RestApiApplication.CreateContainer();

            var posisjonService = _container.Resolve <PosisjonsService>();

            var posisjonForLag1 = posisjonService.HentforLag(givenLag[0].LagId);

            Assert.AreEqual(2, posisjonForLag1.Posisjoner.Count, "Feil antall posisjoner etter restart - lag1");

            var posisjonForLag2 = posisjonService.HentforLag(givenLag[1].LagId);

            Assert.AreEqual(2, posisjonForLag2.Posisjoner.Count, "Feil antall posisjoner etter restart - lag2");

            var posisjon = posisjonForLag1.Posisjoner[0];

            Assert.AreEqual(latitude + 5, posisjon.Latitude, "Latitude");
            Assert.AreEqual(longitude + 5, posisjon.Longitude, "Longitude");
        }