public async Task Set_Series_Read_Order()
        {
            var series = await SeriesHelpers.CreateValidSeriesWithBooks();

            var repository = new SeriesRepository(_fixture.Context);

            (await repository.ExistsAsync(series.Id)).Should().BeTrue();

            var sut = await repository.LoadAsync(series.Id);

            var seriesId = sut.Id;

            sut.Should().NotBeNull();
            sut.Books.Count.Should().Be(2);
            sut.Books.SingleOrDefault(b => b.Instalment == 1)?.BooksId
            .Should().Be(sut.Books.SingleOrDefault(r => r.Book.Title == "Book 1")?.BooksId);
            sut.Books.SingleOrDefault(b => b.Instalment == 2)?.BooksId
            .Should().Be(sut.Books.SingleOrDefault(r => r.Book.Title == "Book 2")?.BooksId);

            // Re-order collection
            sut = await repository.LoadAsync(series.Id);

            sut.Books.Single(b => b.Instalment == 1).Instalment = 0;
            sut.Books.Single(b => b.Instalment == 2).Instalment = 1;
            sut.Books.Single(b => b.Instalment == 0).Instalment = 2;

            await repository.SaveAsync();

            sut = await repository.LoadAsync(series.Id);

            sut.Books.SingleOrDefault(b => b.Instalment == 2)?.BooksId
            .Should().Be(sut.Books.SingleOrDefault(r => r.Book.Title == "Book 1")?.BooksId);
            sut.Books.SingleOrDefault(b => b.Instalment == 1)?.BooksId
            .Should().Be(sut.Books.SingleOrDefault(r => r.Book.Title == "Book 2")?.BooksId);
        }
        public async Task Update_Series_Books()
        {
            var series = await SeriesHelpers.CreateValidSeriesWithBooks();

            var repository = new SeriesRepository(_fixture.Context);

            (await repository.ExistsAsync(series.Id)).Should().BeTrue();

            var sut = await repository.LoadAsync(series.Id);

            var seriesId = sut.Id;

            sut.Should().NotBeNull();
            sut.Books.Count.Should().Be(2);

            // Add one more book to series
            var book1 = await BookHelpers.CreateValidBook();

            var book2 = await BookHelpers.CreateValidBook();

            var newReadOrder = new List <ReadOrder>
            {
                ReadOrder.NewReadOrder(book1, null, 3),
                ReadOrder.NewReadOrder(book2, null, 4)
            };
            await SeriesHelpers.UpdateSeriesReadOrder(sut.Id, newReadOrder);

            sut = await repository.LoadAsync(series.Id);

            sut.Books.Count.Should().Be(4);
            sut.Id.Should().Be(seriesId);
        }
        public async Task Series_inserted_to_database()
        {
            var series = await SeriesHelpers.CreateValidSeries();

            var repository = new SeriesRepository(_fixture.Context);

            (await repository.ExistsAsync(series.Id)).Should().BeTrue();
        }
Example #4
0
        public TakeoffFactorChart()
        {
            Assembly assembly = Assembly.GetExecutingAssembly();
            string   resource = "F5E3.data.TakeoffFactor.json";

            runwayTemperatureSeries = SeriesHelpers.CompoundChartSeriesFromResourceJSON(assembly, resource, "RunwayTemperature");
            maxThrust    = SeriesHelpers.ChartSeriesFromResourceJSON(assembly, resource, "MaxThrust");
            maxThrustAI  = SeriesHelpers.ChartSeriesFromResourceJSON(assembly, resource, "MaxThrustAntiIce");
            _antiIceOn   = false;
            _pressureAlt = F5MissionPlanner.DefaultPA;
            _runwayTemp  = F5MissionPlanner.DefaultTemp;
        }
        public TakeOffAndObsticalClearanceSpeedChart(GrossWeightAndCGPositionChart grossWeightAndCGPositionChart)
        {
            GrossWeightAndCGPositionChart = grossWeightAndCGPositionChart;
            Assembly assembly = Assembly.GetExecutingAssembly();
            string   resource = "F5E3.data.TakeOffSpeed.json";

            takeoffSpeedSeries           = SeriesHelpers.CompoundChartSeriesFromResourceJSON(assembly, resource, "TakeoffSpeed");
            obstacleClearanceSpeedSeries = SeriesHelpers.CompoundChartSeriesFromResourceJSON(assembly, resource, "ObstacleClearanceSpeed");
            _takeoffGrossWeight          = grossWeightAndCGPositionChart.GrossWeight;
            _cg = grossWeightAndCGPositionChart.CG;

            Calculate();
        }
Example #6
0
        public TimeFuelDistanceClimb()
        {
            Assembly assembly = Assembly.GetExecutingAssembly();
            string   resource = "F5E3.data.TimeFuelDistanceClimbMil.json";

            takeoffFactorSeries = SeriesHelpers.CompoundChartSeriesFromResourceJSON(assembly, resource, "TakeoffFactor");
            timeSeries          = SeriesHelpers.CompoundChartSeriesFromResourceJSON(assembly, resource, "Time");
            fuelSeries          = SeriesHelpers.CompoundChartSeriesFromResourceJSON(assembly, resource, "Fuel");
            distanceSeries      = SeriesHelpers.CompoundChartSeriesFromResourceJSON(assembly, resource, "Distance");
            _maxClimb           = F5MissionPlanner.DefaultClimbProfile;
            _takeoffFactor      = F5MissionPlanner.DefaultTakeoffFactor;
            _takeoffGrossWeight = F5MissionPlanner.DefaultEmptyWeight;
            _dragIndex          = F5MissionPlanner.DefaultDragIndex;
            Calculate();
        }
        public async Task Remove_Series()
        {
            var series = await SeriesHelpers.CreateValidSeries();

            var repository = new SeriesRepository(_fixture.Context);

            (await repository.ExistsAsync(series.Id)).Should().BeTrue();

            await SeriesHelpers.RemoveSeries(series.Id);

            var sut = await repository.GetAsync(series.Id);

            await _fixture.Context.Entry(sut).ReloadAsync();

            (await repository.ExistsAsync(series.Id)).Should().BeFalse();
        }
Example #8
0
        public GrossWeightAndCGPositionChart()
        {
            Assembly assembly = Assembly.GetExecutingAssembly();
            string   resource = "F5E3.data.AircraftGrossWeightAndCGPosition.json";

            inboardSeries         = SeriesHelpers.CompoundChartSeriesFromResourceJSON(assembly, resource, "Inboard");
            centerSeries          = SeriesHelpers.CompoundChartSeriesFromResourceJSON(assembly, resource, "Center");
            ammoSeries            = SeriesHelpers.CompoundChartSeriesFromResourceJSON(assembly, resource, "Ammo");
            outboardSeries        = SeriesHelpers.ChartSeriesFromResourceJSON(assembly, resource, "Outboard");
            missileSeries         = SeriesHelpers.ChartSeriesFromResourceJSON(assembly, resource, "Missile");
            _inboardStoresWeight  = 0;
            _outboardStoresWeight = 0;
            _centerStoresWeight   = 0;
            _ammo        = 0;
            _hasMissiles = false;
            Calculate();
        }
        public async Task Update_Series()
        {
            var series = await SeriesHelpers.CreateValidSeries();

            series.Name.Should().Be("Series to be");

            var sut = Series.Create(series.Id,
                                    "Series of books",
                                    @"\\pics\logo.jpg",
                                    "...");

            await SeriesHelpers.UpdateSeries(sut);

            await _fixture.Context.Entry(series).ReloadAsync();

            series.Name.Should().Be("Series of books");
        }
        public async Task Update_Series_LogoPath()
        {
            var series = await SeriesHelpers.CreateValidSeries();

            var repository = new SeriesRepository(_fixture.Context);

            (await repository.ExistsAsync(series.Id)).Should().BeTrue();

            var sut = await repository.GetAsync(series.Id);

            var seriesId = sut.Id;

            sut.Should().NotBeNull();
            sut.PicturePath.Should().Be(@"\\filepath\file.jpg");

            await SeriesHelpers.UpdateSeriesPicturePath(sut.Id, @"\\filepath\newFile.jpg");

            await _fixture.Context.Entry(sut).ReloadAsync();

            sut.PicturePath.Should().Be(@"\\filepath\newFile.jpg");
            sut.Id.Should().Be(seriesId);
        }
        public async Task Update_Series_Name()
        {
            var series = await SeriesHelpers.CreateValidSeries();

            var repository = new SeriesRepository(_fixture.Context);

            (await repository.ExistsAsync(series.Id)).Should().BeTrue();

            var sut = await repository.GetAsync(series.Id);

            var seriesId = sut.Id;

            sut.Should().NotBeNull();
            sut.Name.Should().Be("Series to be");

            await SeriesHelpers.UpdateSeriesName(sut.Id, "Series of more books");

            await _fixture.Context.Entry(sut).ReloadAsync();

            sut.Name.Should().Be("Series of more books");
            sut.Id.Should().Be(seriesId);
        }
        public async Task Update_Series_Description()
        {
            var series = await SeriesHelpers.CreateValidSeries();

            var repository = new SeriesRepository(_fixture.Context);

            (await repository.ExistsAsync(series.Id)).Should().BeTrue();

            var sut = await repository.GetAsync(series.Id);

            var seriesId = sut.Id;

            sut.Should().NotBeNull();
            sut.Description.Should().Contain("Best books in the world!");

            await SeriesHelpers.UpdateSeriesDescription(sut.Id, "Bacon ipsum...");

            await _fixture.Context.Entry(sut).ReloadAsync();

            sut.Description.Should().Contain("Bacon ipsum");
            sut.Id.Should().Be(seriesId);
        }
Example #13
0
        public void ChartSeriesTests()
        {
            var    assembly       = "F5E3.dll";
            var    resource       = "F5E3.data.AircraftGrossWeightAndCGPosition.json";
            double outboardWeight = 1318;
            double inboardWeight  = 1306;
            double centerWeight   = 2174;
            double ammoWeight     = 394;
            double missileWeight  = 342;

            //var outboard = CGPositionTestData.OutboardSeries.Interpolate(outboardWeight);
            var outboard = SeriesHelpers.ChartSeriesFromResourceJSON(assembly, resource, "Outboard")
                           .Interpolate(outboardWeight);

            Assert.AreEqual(17.9, outboard.SigFigs(3));

            var inboard = SeriesHelpers.CompoundChartSeriesFromResourceJSON(assembly, resource, "Inboard")
                          .Interpolate(inboardWeight, outboardWeight);

            Assert.AreEqual(18.9, inboard.SigFigs(3));

            var centerLine = SeriesHelpers.CompoundChartSeriesFromResourceJSON(assembly, resource, "Center")
                             .Interpolate(centerWeight, inboardWeight + outboardWeight);

            Assert.AreEqual(16.3, centerLine.SigFigs(3)); // this one should be looked at

            var missile = SeriesHelpers.ChartSeriesFromResourceJSON(assembly, resource, "Missile")
                          .Interpolate(inboardWeight + outboardWeight + centerWeight);

            Assert.AreEqual(0.598, missile.SigFigs(3));

            var gun = SeriesHelpers.CompoundChartSeriesFromResourceJSON(assembly, resource, "Ammo")
                      .Interpolate(ammoWeight, outboardWeight + inboardWeight + centerWeight + missileWeight);

            Assert.AreEqual(-3.98, gun.SigFigs(3));

            Assert.AreEqual(12.9, (centerLine + missile + gun).SigFigs(3));
        }
        public void Invalid_Series()
        {
            Func <Task> action = async() => { await SeriesHelpers.CreateInvalidSeries(); };

            action.Should().ThrowAsync <ArgumentException>();
        }