Пример #1
0
        public async Task CreateTamagochi_Success()
        {
            var command = new CreateTamagochiCommand()
            {
                BirthDateTime = DateTime.UtcNow,
                Happiness     = 1,
                Hungry        = 1,
                Name          = "Joy",
                Type          = 1
            };
            var response = await _createTamagochiCommandHandler.Handle(command, default);

            Assert.IsTrue(response.Ok);
        }
Пример #2
0
        public async Task CreateTamagochi_WithWrongType_Fail()
        {
            var command = new CreateTamagochiCommand()
            {
                BirthDateTime = DateTime.UtcNow,
                Happiness     = 1,
                Hungry        = 1,
                Name          = "Joy",
                Type          = -1
            };
            var result = await _createTamagochiCommandHandler.Handle(command, default);

            Assert.IsTrue(!result.Ok);
        }
Пример #3
0
        public async Task <ActionResult> Create(int type, string name)
        {
            GetListTamagochiTypesQuery query = new GetListTamagochiTypesQuery();

            query.Filter = tamagochiType => tamagochiType.Id == type;

            var tamagochiTypeId = _mediator.Send(query).Result.RequestResult.SingleOrDefault().Id;

            CreateTamagochiCommand tamagochi = new CreateTamagochiCommand()
            {
                Type = tamagochiTypeId, Name = name, BirthDateTime = DateTime.UtcNow, Happiness = 70, Hungry = 30
            };
            var result = await _mediator.Send(tamagochi);

            return(Ok(result.RequestResult));
        }