public void TwoNonEmptyStringsWithDifferentValueShouldNotBeEqual(string s1, string s2) { var r1 = NonEmptyString.TryCreate(s1, (NonEmptyString)"Value"); var r2 = NonEmptyString.TryCreate(s2, (NonEmptyString)"Value"); Helper.ShouldNotBeEqual(r1, r2); }
public void TwoNonEmptyStringsWithSameValueShouldBeEqual() { var r1 = NonEmptyString.TryCreate("v1", (NonEmptyString)"Value"); var r2 = NonEmptyString.TryCreate("v1", (NonEmptyString)"Value"); Helper.ShouldBeEqual(r1, r2); }
public void ItShouldBePossibleToImplicitlyCastNonEmptyStringToString() { var value = Extensions.GetValue(() => NonEmptyString.TryCreate("1", (NonEmptyString)"Value")); string castResult = value; castResult.ShouldBeOfType <string>(); }
public Customer(PositiveInt id, Surname surname, Name name, PhoneNumber phoneNumber, Address address, byte[] versionInt) : this() { Id = id; Surname = surname; Name = name; PhoneNumber = phoneNumber; Address = address; VersionInt = versionInt; NonEmptyString.TryCreate(Convert.ToBase64String(versionInt), (NonEmptyString)"Value").EnsureIsNotFaliure(); }
public static IResult <IdVersion, NonEmptyString> TryCreate(int id, string version, NonEmptyString idField, NonEmptyString versionField) { var idResult = PositiveInt.TryCreate(id, idField); var versionResult = NonEmptyString.TryCreate(version, versionField); var result = new IResult <NonEmptyString>[] { idResult, versionResult }.IfAtLeastOneFailCombineElseReturnOk(); return(result.OnSuccess(() => GetOkResult(new IdVersion(idResult.Value, versionResult.Value)))); }
public static IResult <OrderBy, NonEmptyString> TryCreate(string column, bool ascending) { var columnResult = NonEmptyString.TryCreate(column, (NonEmptyString)nameof(Column)); return(columnResult.OnSuccess(() => GetOkResult(new OrderBy(columnResult.Value, ascending)))); }
public void NonEmptyStringCannotBeCreatedFromEmptyValue() { var result = NonEmptyString.TryCreate(string.Empty, (NonEmptyString)"Value"); result.IsSuccess.ShouldBeFalse(); }
public void NonEmptyStringCanBeCreatedFromNonEmptyValue() { var result = NonEmptyString.TryCreate("x", (NonEmptyString)"Value"); result.IsSuccess.ShouldBeTrue(); }