public void AddAttribute_InvalidAttribute_Throws(Fb2Node instance) { instance.Should().NotBe(null); if (!instance.AllowedAttributes.Any()) { return; } //instance // .Invoking(i => i.AddAttribute(() => new Fb2Attribute("testK", ""))) // .Should() // .ThrowExactly<InvalidAttributeException>(); instance .Invoking(i => i.AddAttribute(() => new Fb2Attribute("", "testV"))) .Should() .ThrowExactly <InvalidAttributeException>(); //instance // .Invoking(i => i.AddAttribute(new Fb2Attribute("testK", ""))) // .Should() // .ThrowExactly<InvalidAttributeException>(); instance .Invoking(i => i.AddAttribute(new Fb2Attribute("", "testV"))) .Should() .ThrowExactly <InvalidAttributeException>(); //instance // .Invoking(i => i.AddAttribute(new Fb2Attribute("testK", ""))) // .Should() // .ThrowExactly<InvalidAttributeException>(); instance .Invoking(i => i.AddAttribute(new Fb2Attribute("", "testV"))) .Should() .ThrowExactly <InvalidAttributeException>(); instance .Invoking(i => i.AddAttributes(new Fb2Attribute("", ""), new Fb2Attribute("", ""))) .Should() .ThrowExactly <InvalidAttributeException>(); instance .Invoking(i => i.AddAttributes( new List <Fb2Attribute> { new Fb2Attribute("testKey", ""), new Fb2Attribute("", "testValue") } )) .Should() .ThrowExactly <InvalidAttributeException>(); }
public void AddAttribute_EmptyOrNull_Throws(Fb2Node instance) { instance.Should().NotBe(null); if (!instance.AllowedAttributes.Any()) { return; } instance .Invoking(i => i.AddAttribute((Fb2Attribute)null)) .Should() .ThrowExactly <ArgumentNullException>(); instance .Invoking(i => i.AddAttributeAsync(null)) .Should() .ThrowExactlyAsync <ArgumentNullException>(); instance .Invoking(i => i.AddAttributes()) .Should() .ThrowExactly <ArgumentNullException>(); instance .Invoking(i => i.AddAttributes(Array.Empty <Fb2Attribute>())) .Should() .ThrowExactly <ArgumentNullException>(); instance .Invoking(i => i.AddAttributes((List <Fb2Attribute>)null)) .Should() .ThrowExactly <ArgumentNullException>(); //instance // .Invoking(i => i.AddAttributes(new Dictionary<string, string>())) // .Should() // .ThrowExactly<ArgumentNullException>(); }
public void AddAttribute_NotAllowedAttribute_Throws(Fb2Node instance) { instance.Should().NotBe(null); if (!instance.AllowedAttributes.Any()) { return; } instance .Invoking(i => i.AddAttribute(new Fb2Attribute("NotExistingKey", "NotExistingValue"))) .Should() .ThrowExactly <UnexpectedAtrributeException>(); }
public void AddAttribute_NoAttributesAllowed_Throws(Fb2Node instance) { instance.Should().NotBe(null); if (instance.AllowedAttributes.Any()) { return; } instance .Invoking(i => i.AddAttribute(new Fb2Attribute("testKey", "testValue"))) .Should() .ThrowExactly <NoAttributesAllowedException>() .WithMessage($"Node '{instance.Name}' has no allowed attributes."); instance .Invoking(i => i.AddAttribute(() => new Fb2Attribute("testKey", "testValue"))) .Should() .ThrowExactly <NoAttributesAllowedException>() .WithMessage($"Node '{instance.Name}' has no allowed attributes."); instance .Invoking(i => i.AddAttribute(new Fb2Attribute("testKey", "testValue"))) .Should() .ThrowExactly <NoAttributesAllowedException>() .WithMessage($"Node '{instance.Name}' has no allowed attributes."); instance .Invoking(i => i.AddAttributes( new Fb2Attribute("testKey", "testValue"), new Fb2Attribute("testKey2", "testValue2"))) .Should() .ThrowExactly <NoAttributesAllowedException>() .WithMessage($"Node '{instance.Name}' has no allowed attributes."); instance .Invoking(i => i.AddAttributes( new List <Fb2Attribute> { new Fb2Attribute("testKey", "testValue"), new Fb2Attribute("testKey2", "testValue2") })) .Should() .ThrowExactly <NoAttributesAllowedException>() .WithMessage($"Node '{instance.Name}' has no allowed attributes."); instance .Invoking(async i => await i.AddAttributeAsync(() => Task.FromResult(new Fb2Attribute("testKey", "testValue")))) .Should() .ThrowExactlyAsync <NoAttributesAllowedException>() .WithMessage($"Node '{instance.Name}' has no allowed attributes."); }
public void AddAttribute_Whitespaces_Throws(Fb2Node instance) { instance.Should().NotBe(null); if (!instance.AllowedAttributes.Any()) { return; } instance // whitespace .Invoking(i => i.AddAttribute(new Fb2Attribute(" NotExistingKey", "NotExistingValue"))) .Should() .ThrowExactly <UnexpectedAtrributeException>(); instance // whitespace .Invoking(i => i.AddAttribute(new Fb2Attribute(" NotExistingKey", "NotExistingValue"))) .Should() .ThrowExactly <UnexpectedAtrributeException>(); instance .Invoking(i => i.AddAttribute(new Fb2Attribute('\t' + "NotExistingKey", "NotExistingValue"))) .Should() .ThrowExactly <UnexpectedAtrributeException>(); instance .Invoking(i => i.AddAttribute(new Fb2Attribute(Environment.NewLine + "NotExistingKey", "NotExistingValue"))) .Should() .ThrowExactly <UnexpectedAtrributeException>(); instance .Invoking(i => i.AddAttribute(new Fb2Attribute('\n' + "NotExistingKey", "NotExistingValue"))) .Should() .ThrowExactly <UnexpectedAtrributeException>(); instance .Invoking(i => i.AddAttribute(new Fb2Attribute('\r' + "NotExistingKey", "NotExistingValue"))) .Should() .ThrowExactly <UnexpectedAtrributeException>(); }