mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
add IsValidHttpOrHttpsUrlShould tests
This commit is contained in:
parent
2f600ecc81
commit
334666c335
4 changed files with 102 additions and 66 deletions
|
|
@ -0,0 +1,40 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using FilterLists.Services.Extensions;
|
||||
using Xunit;
|
||||
|
||||
namespace FilterLists.Services.Tests.Extensions.Collection
|
||||
{
|
||||
public class AddIfNotNullOrEmptyShould
|
||||
{
|
||||
public AddIfNotNullOrEmptyShould() =>
|
||||
sut = new Collection<string>();
|
||||
|
||||
private readonly ICollection<string> sut;
|
||||
private string item;
|
||||
|
||||
[Fact]
|
||||
public void AddIfNotNullOrEmpty()
|
||||
{
|
||||
item = "item";
|
||||
sut.AddIfNotNullOrEmpty(item);
|
||||
Assert.Contains(item, sut);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NotAddIfEmpty()
|
||||
{
|
||||
item = "";
|
||||
sut.AddIfNotNullOrEmpty(item);
|
||||
Assert.DoesNotContain(item, sut);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NotAddIfNull()
|
||||
{
|
||||
item = null;
|
||||
sut.AddIfNotNullOrEmpty(item);
|
||||
Assert.DoesNotContain(item, sut);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using FilterLists.Services.Extensions;
|
||||
using Xunit;
|
||||
|
||||
namespace FilterLists.Services.Tests.Extensions.Collection
|
||||
{
|
||||
public class AddRangeShould
|
||||
{
|
||||
public AddRangeShould() =>
|
||||
sut = new Collection<string>();
|
||||
|
||||
private readonly ICollection<string> sut;
|
||||
private IEnumerable<string> range;
|
||||
|
||||
[Fact]
|
||||
public void AddCollectionOfStrings()
|
||||
{
|
||||
range = new Collection<string> {"item1", "item2"};
|
||||
sut.AddRange(range);
|
||||
Assert.True(!range.Except(sut).Any());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddListOfStrings()
|
||||
{
|
||||
range = new List<string> {"item1", "item2"};
|
||||
sut.AddRange(range);
|
||||
Assert.True(!range.Except(sut).Any());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,66 +0,0 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using FilterLists.Services.Extensions;
|
||||
using Xunit;
|
||||
|
||||
namespace FilterLists.Services.Tests.Extensions
|
||||
{
|
||||
public abstract class CollectionExtensionShould
|
||||
{
|
||||
protected readonly ICollection<string> Sut;
|
||||
|
||||
protected CollectionExtensionShould() =>
|
||||
Sut = new Collection<string>();
|
||||
}
|
||||
|
||||
public class AddIfNotNullOrEmptyShould : CollectionExtensionShould
|
||||
{
|
||||
private string item;
|
||||
|
||||
[Fact]
|
||||
public void AddIfNotNullOrEmpty()
|
||||
{
|
||||
item = "item";
|
||||
Sut.AddIfNotNullOrEmpty(item);
|
||||
Assert.Contains(item, Sut);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NotAddIfEmpty()
|
||||
{
|
||||
item = "";
|
||||
Sut.AddIfNotNullOrEmpty(item);
|
||||
Assert.DoesNotContain(item, Sut);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NotAddIfNull()
|
||||
{
|
||||
item = null;
|
||||
Sut.AddIfNotNullOrEmpty(item);
|
||||
Assert.DoesNotContain(item, Sut);
|
||||
}
|
||||
}
|
||||
|
||||
public class AddRangeShould : CollectionExtensionShould
|
||||
{
|
||||
private IEnumerable<string> range;
|
||||
|
||||
[Fact]
|
||||
public void AddCollectionOfStrings()
|
||||
{
|
||||
range = new Collection<string> {"item1", "item2"};
|
||||
Sut.AddRange(range);
|
||||
Assert.True(!range.Except(Sut).Any());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddListOfStrings()
|
||||
{
|
||||
range = new List<string> {"item1", "item2"};
|
||||
Sut.AddRange(range);
|
||||
Assert.True(!range.Except(Sut).Any());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
using FilterLists.Services.Extensions;
|
||||
using Xunit;
|
||||
|
||||
namespace FilterLists.Services.Tests.Extensions.String
|
||||
{
|
||||
public class IsValidHttpOrHttpsUrlShould
|
||||
{
|
||||
[Fact]
|
||||
public void ReturnFalseIfNotHttpOrHttps()
|
||||
{
|
||||
const string abp = "abp://www.google.com";
|
||||
Assert.False(abp.IsValidHttpOrHttpsUrl());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReturnTrueIfValidHttpsUrl()
|
||||
{
|
||||
const string httpsUrl = "https://www.google.com";
|
||||
Assert.True(httpsUrl.IsValidHttpOrHttpsUrl());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReturnTrueIfValidHttpUrl()
|
||||
{
|
||||
const string httpUrl = "http://www.google.com";
|
||||
Assert.True(httpUrl.IsValidHttpOrHttpsUrl());
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue