Beispiel #1
0
        public void TwoIdVersionsWithDifferentValueShouldNotBeEqual(int id1, int id2, string v1, string v2)
        {
            var r1 = IdVersion.TryCreate(id1, v1, (NonEmptyString)"Value", (NonEmptyString)"Value");
            var r2 = IdVersion.TryCreate(id2, v2, (NonEmptyString)"Value", (NonEmptyString)"Value");

            Helper.ShouldNotBeEqual(r1, r2);
        }
Beispiel #2
0
        public void TwoIdVersionsWithSameValueShouldBeEqual()
        {
            var r1 = IdVersion.TryCreate(1, "v", (NonEmptyString)"Value", (NonEmptyString)"Value");
            var r2 = IdVersion.TryCreate(1, "v", (NonEmptyString)"Value", (NonEmptyString)"Value");

            Helper.ShouldBeEqual(r1, r2);
        }
Beispiel #3
0
        public static IResult <Command, NonEmptyString> TryCreate(int id, string version, string name, string surname, string phoneNumber, string address, Guid commandId)
        {
            var idVersionResult = IdVersion.TryCreate(id, version, (NonEmptyString)nameof(Common.ValueObjects.IdVersion.Id), (NonEmptyString)nameof(Common.ValueObjects.IdVersion.Version));
            var surnameResult   = Surname.TryCreate(surname, (NonEmptyString)nameof(Surname));
            var nameResult      = Name.TryCreate(name, (NonEmptyString)nameof(Name));
            var phoneNameResult = PhoneNumber.TryCreate(phoneNumber, (NonEmptyString)nameof(PhoneNumber));
            var addressResult   = Address.TryCreate(address, (NonEmptyString)nameof(Address));

            var result = new IResult <NonEmptyString>[]
            {
                idVersionResult,
                surnameResult,
                nameResult,
                phoneNameResult,
                addressResult
            }.IfAtLeastOneFailCombineElseReturnOk();

            return(result.OnSuccess(() => GetOkResult(new Command(idVersionResult.Value, surnameResult.Value, nameResult.Value, phoneNameResult.Value, addressResult.Value, commandId))));
        }
Beispiel #4
0
        public void InValidVersionValue_ShouldFail()
        {
            var result = IdVersion.TryCreate(1, string.Empty, (NonEmptyString)"Value", (NonEmptyString)"Value");

            result.IsFailure.ShouldBeTrue();
        }
Beispiel #5
0
        public void ValidValues_ShouldSucceed()
        {
            var result = IdVersion.TryCreate(1, "v", (NonEmptyString)"Value", (NonEmptyString)"Value");

            result.IsSuccess.ShouldBeTrue();
        }
Beispiel #6
0
 private static IdVersion GetValidIdVersion()
 {
     return(Extensions.GetValue(() => IdVersion.TryCreate(1, "v1", (NonEmptyString)nameof(IdVersion.Id), (NonEmptyString)nameof(IdVersion.Version))));
 }