Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        public void TwoNonEmptyStringsWithSameValueShouldBeEqual()
        {
            var r1 = NonEmptyString.TryCreate("v1", (NonEmptyString)"Value");
            var r2 = NonEmptyString.TryCreate("v1", (NonEmptyString)"Value");

            Helper.ShouldBeEqual(r1, r2);
        }
Ejemplo n.º 3
0
        public void ItShouldBePossibleToImplicitlyCastNonEmptyStringToString()
        {
            var    value      = Extensions.GetValue(() => NonEmptyString.TryCreate("1", (NonEmptyString)"Value"));
            string castResult = value;

            castResult.ShouldBeOfType <string>();
        }
Ejemplo n.º 4
0
 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();
 }
Ejemplo n.º 5
0
        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))));
        }
Ejemplo n.º 6
0
        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))));
        }
Ejemplo n.º 7
0
        public void NonEmptyStringCannotBeCreatedFromEmptyValue()
        {
            var result = NonEmptyString.TryCreate(string.Empty, (NonEmptyString)"Value");

            result.IsSuccess.ShouldBeFalse();
        }
Ejemplo n.º 8
0
        public void NonEmptyStringCanBeCreatedFromNonEmptyValue()
        {
            var result = NonEmptyString.TryCreate("x", (NonEmptyString)"Value");

            result.IsSuccess.ShouldBeTrue();
        }