public BrandQueryBuilder UpdateBrand(Guid id, BrandCommand brandCommand) { this.query = @"UPDATE Brands SET Name = @Name WHERE BrandID = @BrandID"; this.parameters.Add("BrandID", id); this.parameters.Add("Name", brandCommand.Name); return(this); }
public void Should_return_a_notification_when_creating_a_new_brand_and_brand_name_is_null() { var brandCommand = new BrandCommand(); Assert.IsFalse(brandCommand.IsValid()); Assert.IsTrue(brandCommand.Notifications.ToList().Any(n => n.Property.Contains(nameof(brandCommand.Name)))); }
public void Should_contain_a_notification_when_creating_a_new_brand_and_brand_name_is_null() { var brandCommand = new BrandCommand(); brandCommand.IsValid(); brandCommand.Notifications.ToList().Should().Contain(n => n.Property.Contains(nameof(brandCommand.Name))); }
public BrandQueryBuilderTests() { this.id = Guid.NewGuid(); this.brandCommand = new BrandCommand { Name = MockString() }; this.brand = new Brand(MockString()); }
public void Should_return_a_notification_when_creating_a_new_brand_with_a_brand_name_greater_than_the_maximum_allowed_size() { var brandCommand = new BrandCommand { Name = this.MockString(Brand.MAXIMUM_NAME_SIZE + 1) }; Assert.IsFalse(brandCommand.IsValid()); Assert.IsTrue(brandCommand.Notifications.ToList().Any(n => n.Property.Contains(nameof(brandCommand.Name)))); }
public void Should_contain_a_notification_when_creating_a_new_brand_with_a_brand_name_lower_than_the_minimum_allowed_size() { var brandCommand = new BrandCommand { Name = this.MockString(Brand.MINIMUM_NAME_SIZE - 1) }; brandCommand.IsValid(); brandCommand.Notifications.ToList().Should().Contain(n => n.Property.Contains(nameof(brandCommand.Name))); }
public void Should_not_contain_notifications_when_creating_a_new_brand_with_valid_requides_properties() { var brandCommand = new BrandCommand { Name = this.MockString(Brand.MINIMUM_NAME_SIZE) }; brandCommand.IsValid(); brandCommand.Notifications.ToList().Should().BeEmpty(); }
public void Should_return_true_when_creating_a_new_brand_with_a_brand_name_between_min_and_max_size() { var brandNameSize = new Random().Next(Brand.MINIMUM_NAME_SIZE, Brand.MAXIMUM_NAME_SIZE); var brandCommand = new BrandCommand { Name = this.MockString(brandNameSize) }; Assert.IsTrue(brandCommand.IsValid()); Assert.IsFalse(brandCommand.Notifications.ToList().Any()); }
public BrandHandlerTests() { this.notFoundBrandId = this.Fixture.Create <Guid>().ToString(); this.brandCommand = new BrandCommand(); this.repository = Substitute.For <IBrandRepository>(); this.brandHandler = new BrandHandler(this.repository); this.brandCommand.Name = this.MockString(); this.repository.CheckBrand(Arg.Is <string>(name => name.Equals(this.brandCommand.Name))).Returns(true); this.repository.CheckBrand(Arg.Is <string>(name => !name.Equals(this.brandCommand.Name))).Returns(false); this.repository.Delete(Arg.Any <Guid>()).Returns(true); this.repository.Delete(Arg.Is <Guid>(id => id.Equals(new Guid(this.notFoundBrandId)))).Returns(false); this.repository.Update(Arg.Any <Guid>(), Arg.Any <BrandCommand>()).Returns(true); this.repository.Update(Arg.Is <Guid>(id => id.Equals(new Guid(this.notFoundBrandId))), Arg.Any <BrandCommand>()).Returns(false); }
public BrandHandlerTests() { this.brandCommand = new BrandCommand(); this.repository = Substitute.For <IBrandRepository>(); this.brandHandler = new BrandHandler(this.repository); }
public IActionResult Put(string id, [FromBody] BrandCommand brandCommand) { var result = this.brandCommandHandler.Update(id, brandCommand); return(this.StatusCode((int)result.StatusCode, result)); }
public IActionResult Post([FromBody] BrandCommand brandCommand) { var result = this.brandCommandHandler.Create(brandCommand); return(this.StatusCode((int)result.StatusCode, result)); }
public static Brand Create(BrandCommand command) => new Brand(command.Name);