Beispiel #1
0
        public async Task UpdateAsync()
        {
            var dataAccess = new NotifyDataAccess(this.Context, Mapper());

            //Act
            var sutCreate    = new CreateNotifyCommandHandler(dataAccess);
            var resultCreate = await sutCreate.Handle(new CreateNotifyCommand
            {
                Data = NotifyTestData.NotifyDTO
            }, CancellationToken.None);

            //Act
            var sutUpdate    = new UpdateNotifyCommandHandler(dataAccess);
            var resultUpdate = await sutUpdate.Handle(new UpdateNotifyCommand
            {
                Data = new Common.DTO.NotifyDTO
                {
                    Id    = resultCreate.Data.Id,
                    Email = "*****@*****.**"
                }
            }, CancellationToken.None);

            //Assert
            Assert.IsTrue(resultUpdate.Succeeded);
        }
        public async Task DeleteAsync()
        {
            var handler = new NotifyDataAccess(this.Context, Mapper());
            var entity  = NotifyTestData.NotifyDTO;
            await handler.SaveAsync(entity);

            var response = await handler.DeleteAsync(entity.Id);

            Assert.IsTrue(response);
        }
        public async Task SaveAsync()
        {
            var handler = new NotifyDataAccess(this.Context, Mapper());
            var entity  = NotifyTestData.NotifyDTO;
            var result  = await handler.SaveAsync(entity);

            var outcome = result.Id != 0;

            Assert.IsTrue(outcome);
        }
        public async Task GetAllAsync()
        {
            var handler = new NotifyDataAccess(this.Context, Mapper());
            var entity  = NotifyTestData.NotifyDTO;
            await handler.SaveAsync(entity);

            var response = await handler.GetAllAsync(new NotifyDTO());

            var outcome = response.Count;

            Assert.IsTrue(outcome == 1);
        }
Beispiel #5
0
        public async Task SaveAsync()
        {
            var dataAccess = new NotifyDataAccess(this.Context, Mapper());

            //Act
            var sutCreate    = new CreateNotifyCommandHandler(dataAccess);
            var resultCreate = await sutCreate.Handle(new CreateNotifyCommand
            {
                Data = NotifyTestData.NotifyDTO
            }, CancellationToken.None);

            Assert.IsTrue(resultCreate.Succeeded);
        }
        public async Task UpdateAsync()
        {
            var handler        = new NotifyDataAccess(this.Context, Mapper());
            var entity         = NotifyTestData.NotifyDTO;
            var originalNotify = entity;
            await handler.SaveAsync(entity);

            entity.Email = new Faker().Person.Email;
            var response = await handler.UpdateAsync(entity);

            var outcome = response.Email.Equals(originalNotify.Email);

            Assert.IsTrue(outcome);
        }
Beispiel #7
0
        public async Task GetAllAsync()
        {
            var dataAccess = new NotifyDataAccess(this.Context, Mapper());

            //Act
            var sutCreate    = new CreateNotifyCommandHandler(dataAccess);
            var resultCreate = await sutCreate.Handle(new CreateNotifyCommand
            {
                Data = NotifyTestData.NotifyDTO
            }, CancellationToken.None);

            //Act
            var sutGetAll    = new GetNotifiesQueryHandler(dataAccess);
            var resultGetAll = await sutGetAll.Handle(new GetNotifiesQuery(), CancellationToken.None);

            Assert.IsTrue(resultGetAll?.Data.Count == 1);
        }
Beispiel #8
0
        public async Task GetAsync()
        {
            var dataAccess = new NotifyDataAccess(this.Context, Mapper());

            //Act
            var sutCreate    = new CreateNotifyCommandHandler(dataAccess);
            var resultCreate = await sutCreate.Handle(new CreateNotifyCommand
            {
                Data = NotifyTestData.NotifyDTO
            }, CancellationToken.None);

            //Act
            var sutGet    = new GetNotifyQueryHandler(dataAccess);
            var resultGet = await sutGet.Handle(new GetNotifyQuery
            {
                Id = resultCreate.Data.Id
            }, CancellationToken.None);

            Assert.IsTrue(resultGet?.Data != null);
        }
Beispiel #9
0
        public async Task DeleteAsync()
        {
            var dataAccess = new NotifyDataAccess(this.Context);
            //Act
            var sutCreate    = new CreateNotifyCommandHandler(dataAccess);
            var resultCreate = await sutCreate.Handle(new CreateNotifyCommand
            {
                Data = NotifyTestData.NotifyDataDTO
            }, CancellationToken.None);


            //Act
            var sutDelete     = new DeleteNotifyCommandHandler(dataAccess);
            var outcomeDelete = await sutDelete.Handle(new DeleteNotifyCommand
            {
                Id = resultCreate.Data.Id
            }, CancellationToken.None);

            //Assert
            Assert.IsTrue(outcomeDelete.Succeeded);
        }