public async Task CreateDish_NewDish_SuccessfullRead() { IServiceCollection services = new ServiceCollection(); services.AddServingDomain() .AddServingApplication() .AddServingInfrastructure("Server=.;Database=RestaurantManagementSystem;Trusted_Connection=True;MultipleActiveResultSets=true", "S0M3 M4G1C UN1C0RNS G3N3R4T3D TH1S S3CR3T"); var serviceProviderFactory = new DefaultServiceProviderFactory(); IServiceProvider serviceProvider = serviceProviderFactory.CreateServiceProvider(services); IMediator Mediator = serviceProvider.GetService <IMediator>(); var createDishCommand = new CreateDishCommand(); createDishCommand.Description = "Vkusno"; createDishCommand.Name = "Vkusna Mandja"; createDishCommand.RecipeId = 1; createDishCommand.Price = new Money(10); var createDishCommandOutput = await Mediator.Send(createDishCommand); var getDishesQuery = new DishesQuery(); var dbDish = (await Mediator.Send(getDishesQuery)).Dishes.FirstOrDefault(dish => dish.Id == createDishCommandOutput.DishId); Assert.AreEqual(dbDish.Id, createDishCommandOutput.DishId); Assert.AreEqual(dbDish.Description, createDishCommand.Description); Assert.AreEqual(dbDish.Name, createDishCommand.Name); Assert.AreEqual(dbDish.Price, createDishCommand.Price); Assert.AreEqual(dbDish.RecipeId, createDishCommand.RecipeId); }
public async Task <ActionResult <GetDishesOutputModel> > GetDishes([FromQuery] DishesQuery dishesQuery) { return(await Send(dishesQuery)); }