public async Task EditAsync_ShouldSuccessfullyEdit() { MapperInitializer.InitializeMapper(); var context = ApplicationDbContextInMemoryFactory.InitializeContext(); await this.SeedDataAsync(context); var asphaltMixtureService = new AsphaltMixtureService(context); var editAsphaltMixtureServiceModel = new EditAsphaltMixtureServiceModel(); var asphaltMixtureId = 1; var asphaltMixtureType = "AMT 3"; editAsphaltMixtureServiceModel.Id = asphaltMixtureId; editAsphaltMixtureServiceModel.Type = asphaltMixtureType; await asphaltMixtureService.EditAsync(editAsphaltMixtureServiceModel); var expectedResult = asphaltMixtureType; var actualResult = asphaltMixtureService .All() .First() .Type; Assert.True(expectedResult == actualResult); }
public async Task EditAsync_WithNonExistingIdShouldThrowArgumentNullException() { MapperInitializer.InitializeMapper(); var context = ApplicationDbContextInMemoryFactory.InitializeContext(); await this.SeedDataAsync(context); var asphaltMixtureService = new AsphaltMixtureService(context); var editAsphaltMixtureServiceModel = new EditAsphaltMixtureServiceModel(); editAsphaltMixtureServiceModel.Id = 3; await Assert.ThrowsAsync <ArgumentNullException>(async() => { await asphaltMixtureService.EditAsync(editAsphaltMixtureServiceModel); }); }
public async Task EditAsync_WithOverMaxNameLengthShouldThrowInvalidOperationException() { MapperInitializer.InitializeMapper(); var context = ApplicationDbContextInMemoryFactory.InitializeContext(); await this.SeedDataAsync(context); var asphaltMixtureService = new AsphaltMixtureService(context); var editAsphaltMixtureServiceModel = new EditAsphaltMixtureServiceModel(); var asphaltMixtureType = "qwertyuiop qwertyuiop qwertyuiop qwertyuiop qwertyuiop"; editAsphaltMixtureServiceModel.Type = asphaltMixtureType; editAsphaltMixtureServiceModel.Id = 1; var message = "Asphalt mixture's type cannot be more than 30 characters."; var exception = await Assert.ThrowsAsync <InvalidOperationException>(async() => { await asphaltMixtureService.EditAsync(editAsphaltMixtureServiceModel); }); Assert.Equal(message, exception.Message); }
public async Task EditAsync_WithExistingNameShouldThrowInvalidOperationException() { MapperInitializer.InitializeMapper(); var context = ApplicationDbContextInMemoryFactory.InitializeContext(); await this.SeedDataAsync(context); var asphaltMixtureService = new AsphaltMixtureService(context); var editAsphaltMixtureServiceModel = new EditAsphaltMixtureServiceModel(); var asphaltMixtureType = "AMT 2"; editAsphaltMixtureServiceModel.Type = asphaltMixtureType; editAsphaltMixtureServiceModel.Id = 1; var message = "Asphalt mixture's type already exists."; var exception = await Assert.ThrowsAsync <InvalidOperationException>(async() => { await asphaltMixtureService.EditAsync(editAsphaltMixtureServiceModel); }); Assert.Equal(message, exception.Message); }