public async Task UpdateFlavorCallsRepositoryMethods() { var id = Guid.NewGuid(); var flavorModel = new FlavorModel { Id = id, Name = "new flavor" }; var flavor = new Flavor { Id = flavorModel.Id, Name = flavorModel.Name }; _repositoryMock .Setup(x => x.UpdateAsync(It.IsAny <Flavor>(), _token, true)) .Returns(Task.FromResult(flavor)); _repositoryMock .Setup(x => x.GetSingleAsync(It.IsAny <Func <IQueryable <Flavor>, IQueryable <Flavor> > >(), _token)) .Returns(Task.FromResult(flavor)); var result = await _service.UpdateAsync(id, flavorModel, _token); Assert.AreEqual(flavorModel.Name, result.Name); _repositoryMock.Verify(x => x.UpdateAsync(It.Is <Flavor>(y => y.Id == id), _token, true), Times.Once); _repositoryMock.Verify(x => x.GetSingleAsync(It.IsAny <Func <IQueryable <Flavor>, IQueryable <Flavor> > >(), _token), Times.Once); _repositoryMock.Verify(x => x.InsertAsync(It.IsAny <Flavor>(), _token, true), Times.Never); _repositoryMock.Verify(x => x.DeleteAsync(It.IsAny <Flavor>(), _token, true), Times.Never); }
public void FlavorModel() { var model = new FlavorModel(); var model2 = Mapper.Map(model); var model3 = Mapper.Map(model2); Assert.IsAssignableFrom(model.GetType(), model3); }
public async Task <IActionResult> PostAsync([FromBody, Required] FlavorModel model, CancellationToken cancellationToken) { if (!ModelState.IsValid) { return(BadRequest(new ApiBadRequestResponse(ModelState))); } try { var result = await _service.CreateAsync(model, cancellationToken); return(CreatedAtRoute("GetFlavor", new { Id = result.Id }, result)); } catch (BadRequestException ex) { return(BadRequest(new ApiErrorResponse(400, ex.Message))); } }
public async Task <IActionResult> PutAsync([FromRoute] Guid id, [FromBody, Required] FlavorModel model, CancellationToken cancellationToken) { if (!ModelState.IsValid) { return(BadRequest(new ApiBadRequestResponse(ModelState))); } try { var result = await _service.UpdateAsync(id, model, cancellationToken); return(Ok(result)); } catch (NotFoundException ex) { return(NotFound(new ApiErrorResponse(404, ex.Message))); } catch (BadRequestException ex) { return(BadRequest(new ApiErrorResponse(400, ex.Message))); } }
public void Models() { AccountModel a = new AccountModel() { AccountId = 1, IsAdmin = true, Password = "******", PlayerId = 1, Username = "" }; EquipmentModel b = new EquipmentModel() { Difficulty = 1, EquipmentId = 1, Modifier = 1, Name = "", PlayerEquipmentId = 1, Price = 1, Type = "" }; FlavorModel c = new FlavorModel() { Bonus = 1, Name = "", Description = "", FlavorId = 1 }; FlavorLootModel d = new FlavorLootModel() { FlavorId = 1, FlavorLootId = 1, LootId = 1 }; LocationLootModel e = new LocationLootModel() { DropRate = 1, LocationId = 1, LocationLootId = 1, LootId = 1 }; LocationModel f = new LocationModel() { Description = "", Difficulty = 1, LocationId = 1, Loot = null, Name = "" }; LootModel g = new LootModel() { Description = "", DropRate = 1, Flavor = new FlavorModel(), FlavorLootId = 1, LocationLootId = 1, LootId = 1, Name = "", PlayerLootId = 1, Price = 1, Quantity = 1 }; PlayerEquipmentModel pe = new PlayerEquipmentModel() { EquipmentId = 1, PlayerEquipmentId = 1, PlayerId = 1 }; PlayerLocationModel pl = new PlayerLocationModel() { LocationId = 1, PlayerId = 1, PlayerLocationId = 1 }; PlayerLootModel plm = new PlayerLootModel() { LootId = 1, PlayerId = 1, PlayerLootId = 1, Quantity = 1 }; PlayerModel pm = new PlayerModel() { Gold = 1, Name = "", PlayerId = 1 }; RecipeLootModel rl = new RecipeLootModel() { LootId = 1, RecipeLootId = 1, RecipeId = 1 }; RecipeModel r = new RecipeModel() { Description = "", Name = "", RecipeId = 1 }; StoreEquipmentModel se = new StoreEquipmentModel() { EquipmentId = 1, StoreEquipmentId = 1, StoreId = 1 }; StoreFlavorModel sf = new StoreFlavorModel() { Bonus = 1, FlavorId = 1, StoreFlavorId = 1, StoreId = 1 }; StoreModel s = new StoreModel() { Description = "", Difficulty = 1, Flavors = null, Name = "", StoreId = 1 }; ErrorViewModel ev = new ErrorViewModel(); LocationViewModel lv = new LocationViewModel(); PlayerViewModel pv = new PlayerViewModel(); StoreViewModel sv = new StoreViewModel() { CurrentVoucher = null, HighestVoucher = 1, InStock = null, Loot = null, NextVoucher = null, Player = null, PlayerEquipment = null, Store = null, StoreId = 1, storeModels = null, Vouchers = null }; MyConfiguration my = new MyConfiguration(); Assert.NotNull(my); Assert.NotNull(ev); Assert.NotNull(lv); Assert.NotNull(pv); Assert.NotNull(sv); Assert.NotNull(a); Assert.NotNull(s); Assert.NotNull(sf); Assert.NotNull(se); Assert.NotNull(r); Assert.NotNull(rl); Assert.NotNull(pm); Assert.NotNull(plm); Assert.NotNull(pl); Assert.NotNull(b); Assert.NotNull(c); Assert.NotNull(d); Assert.NotNull(e); Assert.NotNull(f); Assert.NotNull(g); Assert.NotNull(pe); }
public static Flavor Map(FlavorModel flavor) => new Flavor { FlavorId = flavor.FlavorId, Name = flavor.Name, Description = flavor.Description, };