public async Task EditAsync_ShouldSuccessfullyEdit()
        {
            MapperInitializer.InitializeMapper();
            var context = ApplicationDbContextInMemoryFactory.InitializeContext();

            await this.SeedDataAsync(context);

            var firmService          = new FirmService(context);
            var editFirmServiceModel = new EditFirmServiceModel();
            var firmId   = 1;
            var firmName = "FN 3";

            editFirmServiceModel.Id   = firmId;
            editFirmServiceModel.Name = firmName;

            await firmService.EditAsync(editFirmServiceModel);

            var expectedResult = firmName;
            var actualResult   = firmService
                                 .All()
                                 .First()
                                 .Name;

            Assert.True(expectedResult == actualResult);
        }
        public async Task EditAsync_WithNonExistingIdShouldThrowArgumentNullException()
        {
            MapperInitializer.InitializeMapper();
            var context = ApplicationDbContextInMemoryFactory.InitializeContext();

            await this.SeedDataAsync(context);

            var firmService          = new FirmService(context);
            var editFirmServiceModel = new EditFirmServiceModel();

            editFirmServiceModel.Id = 3;

            await Assert.ThrowsAsync <ArgumentNullException>(async() =>
            {
                await firmService.EditAsync(editFirmServiceModel);
            });
        }
        public async Task EditAsync_WithOverMaxNameLengthShouldThrowInvalidOperationException()
        {
            MapperInitializer.InitializeMapper();
            var context = ApplicationDbContextInMemoryFactory.InitializeContext();

            await this.SeedDataAsync(context);

            var firmService          = new FirmService(context);
            var editFirmServiceModel = new EditFirmServiceModel();
            var firmName             = "qwertyuiop qwertyuiop qwertyuiop qwertyuiop qwertyuiop";

            editFirmServiceModel.Name = firmName;
            editFirmServiceModel.Id   = 1;
            var message = "Firm's Name cannot be more than 50 characters.";

            var exception = await Assert.ThrowsAsync <InvalidOperationException>(async() =>
            {
                await firmService.EditAsync(editFirmServiceModel);
            });

            Assert.Equal(message, exception.Message);
        }
        public async Task EditAsync_WithExistingNameShouldThrowInvalidOperationException()
        {
            MapperInitializer.InitializeMapper();
            var context = ApplicationDbContextInMemoryFactory.InitializeContext();

            await this.SeedDataAsync(context);

            var firmService          = new FirmService(context);
            var editFirmServiceModel = new EditFirmServiceModel();
            var firmName             = "FN 2";

            editFirmServiceModel.Name = firmName;
            editFirmServiceModel.Id   = 1;
            var message = "Firm's name already exists.";

            var exception = await Assert.ThrowsAsync <InvalidOperationException>(async() =>
            {
                await firmService.EditAsync(editFirmServiceModel);
            });

            Assert.Equal(message, exception.Message);
        }