Ejemplo n.º 1
0
        public async Task Starship_Should_Add_WeeksConsumable()
        {
            _entity = await Starship.AddAsync("Name 8", "50", "5 weeks", 1000000);

            _entity.Should().NotBeNull().And.BeOfType(typeof(Starship)).And.BeAssignableTo(typeof(Entity));

            _entity.Id.Should().NotBeEmpty();
            _entity.Name.Should().Be("Name 8");
            _entity.MgltDistance.Should().Be(50);
            _entity.Consumables.Should().Be("5 weeks");
            _entity.AmountStopsRequired.Should().BeGreaterThan(0);
        }
Ejemplo n.º 2
0
        public async Task Starship_Should_Add_NoConsumable()
        {
            _entity = await Starship.AddAsync("Name 2", string.Empty, string.Empty, 1000000);

            _entity.Should().NotBeNull().And.BeOfType(typeof(Starship)).And.BeAssignableTo(typeof(Entity));

            _entity.Id.Should().NotBeEmpty();
            _entity.Name.Should().Be("Name 2");
            _entity.MgltDistance.Should().Be(0);
            _entity.Consumables.Should().BeNullOrEmpty();
            _entity.AmountStopsRequired.Should().Be(0);
        }
Ejemplo n.º 3
0
        public async Task <IEnumerable <StarshipViewModel> > GetAllStarshipsAsync(string mgltDistance)
        {
            decimal distance = !string.IsNullOrWhiteSpace(mgltDistance) ? decimal.Parse(mgltDistance) : 0;

            var starships        = new List <Starship>();
            var starshipsDetails = await _starshipRepository.GetAllStarshipsAsync();

            foreach (var item in starshipsDetails)
            {
                Starship starship = await Starship.AddAsync(item.Name, item.MgltDistance, item.Consumables, distance);

                starships.Add(starship);
            }

            var orderedList = starships.OrderBy(x => x.Name);

            return(_mapper.Map <IEnumerable <StarshipViewModel> >(orderedList).ToList());
        }