public async Task OnCreate_Should_Write_And_Deserialize_Data()
        {
            var userId   = UserId.Create();
            var fullname = Fullname.Create(Faker.Name.FirstName(), Faker.Name.LastName());
            var email    = Email.Create($"{Faker.Random.Word()}@example.com");
            var password = Password.Create("secret");

            await GivenAsync(async repository =>
            {
                var aggregate = new User(userId);
                aggregate.Create(fullname, email, password);

                await repository.Save(aggregate, CancellationToken.None);
            });

            var result = await When(async repository => await repository.Get(userId, CancellationToken.None));

            Then(repository =>
            {
                result.Should().NotBeNull();
                result.Id.Should().Be(userId);
                result.Fullname.Should().Be(fullname);
                result.Email.Should().Be(email);
                result.Password.Should().Be(password);
            });
        }
예제 #2
0
        /// <inheritdoc/>
        public override int GetHashCode()
        {
#pragma warning disable CA1307 // Specify StringComparison
            return(string.IsNullOrEmpty(Fullname) ? 0 : 29 * Fullname.GetHashCode());

#pragma warning restore CA1307 // Specify StringComparison
        }
예제 #3
0
                // Update Contact data when click update button
                private void btnUpdate_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(txtName.Text) && string.IsNullOrEmpty(txtSurname.Text) && string.IsNullOrEmpty(txtPhone.Text))
            {
                MessageBox.Show("Sahələr boş buraxıla bilməz!");
                return;
            }

            Fullname fullname = cmbContact.SelectedItem as Fullname;
            Contacts c        = db.Contacts.Find(fullname.Id);

            c.Name    = txtName.Text;
            c.Surname = txtSurname.Text;
            c.Phone   = txtPhone.Text;

            txtName.Text    = "";
            txtSurname.Text = "";
            txtPhone.Text   = "";

            db.SaveChanges();
            stadium.fillContacts();
            btnUpdate.Visibility = Visibility.Hidden;

            MessageBox.Show("Şəxs yeniləndi!");
        }
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (Fullname != null)
         {
             hashCode = hashCode * 59 + Fullname.GetHashCode();
         }
         if (Firstname != null)
         {
             hashCode = hashCode * 59 + Firstname.GetHashCode();
         }
         if (Lastname != null)
         {
             hashCode = hashCode * 59 + Lastname.GetHashCode();
         }
         if (Nickname != null)
         {
             hashCode = hashCode * 59 + Nickname.GetHashCode();
         }
         if (Systemuserid != null)
         {
             hashCode = hashCode * 59 + Systemuserid.GetHashCode();
         }
         if (Ownerid != null)
         {
             hashCode = hashCode * 59 + Ownerid.GetHashCode();
         }
         return(hashCode);
     }
 }
예제 #5
0
        /// <summary>
        /// TODO:Parsing function
        /// </summary>
        Form IParser <Type, Form> .Parse(Type type)
        {
            _ = type ?? throw new ArgumentNullException(nameof(type));

            var name = new Fullname()
            {
                Name      = type.Name,
                Namespace = type.Namespace,
                Layer     = type.AssemblyQualifiedName
            };

            var aspects = type
                          .GetProperties()
                          .Select(property => new Aspect()
            {
                Name = property.Name,
                //TODO:0 Registry
                Form = (this as IParser <Type, Form>).Parse(property.PropertyType)
            })
            ;

            var result = new Form()
            {
                Fullname = name,
                Aspects  = aspects
            };

            return(result);
        }
예제 #6
0
        private string getNamevCard()
        {
            string[] name = Fullname.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            string   res  = "N:";

            switch (name.Length)
            {
            case 1:
                res += name[0] + ";;;;";
                break;

            case 2:
                res += name[1] + ";" + name[0] + ";;;";
                break;

            case 3:
                res += name[2] + ";" + name[0] + ";" + name[1] + ";;";
                break;

            case 4:
                res += name[3] + ";" + name[1] + ";" + name[2] + ";" + name[0] + ";";
                break;

            case 5:
                res += name[3] + ";" + name[1] + ";" + name[2] + ";" + name[0] + ";" + name[4];
                break;
            }
            return(res);
        }
        public async Task OnUpdatePassword_Should_Update_ReadModel()
        {
            var userId   = UserId.Create();
            var fullname = Fullname.Create(Faker.Name.FirstName(), Faker.Name.LastName());
            var email    = Email.Create($"{Faker.Random.Word()}@example.com");
            var password = Password.Create("secret");


            await GivenAsync(async repository =>
            {
                var aggregate = new User(userId);
                aggregate.Create(fullname, email, password);
                await repository.Save(aggregate, CancellationToken.None);
            });

            var updatedPassword = Password.Create(Faker.Random.Word());

            await When(async repository =>
            {
                var savedUser = await repository.Get(userId, CancellationToken.None);
                savedUser.UpdatePassword(updatedPassword);
                await repository.Save(savedUser, CancellationToken.None);
            });

            await Then <IDocumentRepository <UserModel> >(async (mediator, repository) =>
            {
                var user = await repository.SingleOrDefault(u => u.Id == userId.Id.ToString());
                user.Should().NotBeNull();
                user.Password.Should().Be(updatedPassword.ToString());
            });
        }
예제 #8
0
        /// <summary>
        /// Returns true if SecurityContractApplication instances are equal
        /// </summary>
        /// <param name="other">Instance of SecurityContractApplication to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(SecurityContractApplication other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Fullname == other.Fullname ||
                     Fullname != null &&
                     Fullname.Equals(other.Fullname)
                     ) &&
                 (
                     ApplicationFunctions == other.ApplicationFunctions ||
                     ApplicationFunctions != null &&
                     other.ApplicationFunctions != null &&
                     ApplicationFunctions.SequenceEqual(other.ApplicationFunctions)
                 ) &&
                 (
                     DataPolicies == other.DataPolicies ||
                     DataPolicies != null &&
                     other.DataPolicies != null &&
                     DataPolicies.SequenceEqual(other.DataPolicies)
                 ));
        }
예제 #9
0
        public Atributo RelacionAtributo()
        {
            if (atrib.DirIndice == -1)
            {
                return(null);
            }
            string[] arch = Fullname.Split('\\');
            string   dicc = base.Fullname.Substring(0, Fullname.LastIndexOf('\\')) + '\\' + arch[arch.Length - 2] + ".dd";

            using (BinaryReader reader = new BinaryReader(File.Open(dicc, FileMode.Open)))
            {
                reader.BaseStream.Seek(atrib.DirIndice, SeekOrigin.Begin);
                string nomb = "";
                char[] name = reader.ReadChars(30);
                foreach (char c in name)
                {
                    nomb += c;
                }
                long dir = reader.ReadInt64();
                char tipo;
                long dirIn, dirsig;
                int  l, tipoI;

                tipo   = reader.ReadChar();
                l      = reader.ReadInt32();
                tipoI  = reader.ReadInt32();
                dirIn  = reader.ReadInt64();
                dirsig = reader.ReadInt64();

                Console.WriteLine("{0}, {1}, {2}, {3}, {4}, {5}, {6}", nomb, dir, tipo, l, tipoI, dirIn, dirsig);
                return(new Atributo(nomb, dir, tipo, l, tipoI, dirIn, dirsig));
            }
        }
예제 #10
0
        public Employee ToEmployee()
        {
            var    split = Fullname.Split(" ");
            string name;

            try
            {
                name = split[0];
            }
            catch (IndexOutOfRangeException)
            {
                name = "";
            }
            return(new Employee
            {
                Id = Id,
                Fullname = Fullname,
                Name = name,
                // TBD
                DepartmentId = 2,
                PositionId = Post.Id,

                IsActive = DismissedDate == null,
            });
        }
        public void OnCreateUser_Should_Emit_UserCreatedEvent()
        {
            Given(aggregate => { });

            var fullname = Fullname.Create(Faker.Name.FirstName(), Faker.Name.LastName());
            var email    = Email.Create($"{Faker.Random.Word()}@example.com");
            var password = Password.Create(Faker.Random.Word());

            var start = DateTimeUtc.Now();

            When(aggregate =>
            {
                aggregate.Create(
                    fullname,
                    email,
                    password);
            });
            var end = DateTimeUtc.Now();

            Then(aggregate =>
            {
                aggregate.Fullname.Should().Be(fullname);
                aggregate.Email.Should().Be(email);
                aggregate.Password.Should().Be(password);
            });

            Then <UserCreatedEvent>((aggregate, @event) =>
            {
                @event.Firstname.Should().Be(fullname.Firstname);
                @event.Lastname.Should().Be(fullname.Lastname);
                @event.Email.Should().Be(email.ToString());
                @event.Password.Should().Be(password.ToString());
                @event.CreatedOn.Should().NotBe(default);
예제 #12
0
        public void Lastname_TrailingSpaces__OK()
        {
            //arrange
            var x = new Fullname("   Hans Solo    ");

            // assert
            Assert.IsTrue(x.Lastname == "Solo");
        }
예제 #13
0
        public void Lastname2__OK()
        {
            // arrange
            var x = new Fullname("Alpha   Bravo     Charlie       Delta");

            // assert
            Assert.IsTrue(x.Lastname == "Delta");
        }
예제 #14
0
        public void FirstName2__OK()
        {
            // arrange
            var x = new Fullname("Alpha   Bravo     Charlie       Delta");

            // assert
            Assert.IsTrue(x.Givennames == "Alpha Bravo Charlie");
        }
예제 #15
0
        public void Lastame1__OK()
        {
            // arrange
            var x = new Fullname("Hans Solo");

            // assert
            Assert.IsTrue(x.Lastname == "Solo");
        }
예제 #16
0
        public void FirstName_LeadingSpaces__OK()
        {
            //arrange
            var x = new Fullname("   Hans Solo");

            // assert
            Assert.IsTrue(x.Givennames == "Hans");
        }
예제 #17
0
 public int CompareTo(ContactData other)
 {
     if (Object.ReferenceEquals(other, null))
     {
         return(1);
     }
     return(Fullname.CompareTo(other.Fullname));
 }
예제 #18
0
        public override void WriteDefinition(TextWriter writer)
        {
            writer.WriteLine("    using Newtonsoft.Json;");
            var converterName = Fullname.Replace(".", "") + "Converter";

            writer.Write("    [Newtonsoft.Json.JsonConverter(typeof(");
            writer.Write(converterName);
            writer.WriteLine("))]");
            base.WriteDefinition(writer);


            writer.Write("    internal class ");
            writer.Write(converterName);
            writer.Write(" : Newtonsoft.Json.Converters.CustomCreationConverter<");
            writer.Write(NetType);
            writer.WriteLine(">");
            writer.WriteLine("    {");
            writer.WriteLine("        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)");
            writer.WriteLine("        {");
            writer.WriteLine("            if (reader.TokenType == JsonToken.Null)");
            writer.WriteLine("                return null;");
            writer.WriteLine("");
            writer.WriteLine("            var jObject = (JObject)serializer.Deserialize(reader);");
            writer.WriteLine("            var localReader = new JTokenReader(jObject);");
            writer.Write("            var val = (");
            writer.Write(NetType);
            writer.WriteLine(")base.ReadJson(localReader, objectType, existingValue, serializer);");
            writer.WriteLine("");
            foreach (var baseType in _baseTypes)
            {
                writer.WriteLine("            localReader = new JTokenReader(jObject);");
                writer.Write("            val.As");
                writer.Write(baseType.TypeHandler.Fullname.Replace(".", ""));
                writer.Write(" = serializer.Deserialize<");
                writer.Write(baseType.TypeHandler.NetType);
                writer.WriteLine(">(localReader);");
            }
            writer.WriteLine("");
            writer.WriteLine("            return val;");
            writer.WriteLine("        }");
            writer.WriteLine("");
            writer.WriteLine("		  public override bool CanConvert(Type objectType)");
            writer.WriteLine("        {");
            writer.Write("            return objectType == typeof(");
            writer.Write(NetType);
            writer.WriteLine(");");
            writer.WriteLine("        }");
            writer.WriteLine("");
            writer.Write("        public override ");
            writer.Write(NetType);
            writer.WriteLine(" Create(Type objectType)");
            writer.WriteLine("        {");
            writer.Write("            return (");
            writer.Write(NetType);
            writer.WriteLine(") Activator.CreateInstance(objectType);");
            writer.WriteLine("        }");
            writer.WriteLine("    }");
        }
예제 #19
0
        public void ToString2__OK()
        {
            // arrange
            var testname = "    Hans       Solo      ";
            var x        = new Fullname(testname);

            // assert
            Assert.IsTrue(x.ToString() == testname);
        }
        public void Create(Fullname fullname, Email email, Password password)
        {
            var @event = new UserCreatedEvent(
                Id,
                fullname.Firstname,
                fullname.Lastname,
                email.ToString(),
                password.ToString());

            Emit(@event);
        }
예제 #21
0
        /// <summary>
        /// Returns true if InlineResponseDefault5Value instances are equal
        /// </summary>
        /// <param name="other">Instance of InlineResponseDefault5Value to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(InlineResponseDefault5Value other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     OdataEtag == other.OdataEtag ||
                     OdataEtag != null &&
                     OdataEtag.Equals(other.OdataEtag)
                     ) &&
                 (
                     Nickname == other.Nickname ||
                     Nickname != null &&
                     Nickname.Equals(other.Nickname)
                 ) &&
                 (
                     Fullname == other.Fullname ||
                     Fullname != null &&
                     Fullname.Equals(other.Fullname)
                 ) &&
                 (
                     Firstname == other.Firstname ||
                     Firstname != null &&
                     Firstname.Equals(other.Firstname)
                 ) &&
                 (
                     Lastname == other.Lastname ||
                     Lastname != null &&
                     Lastname.Equals(other.Lastname)
                 ) &&
                 (
                     Azureactivedirectoryobjectid == other.Azureactivedirectoryobjectid ||
                     Azureactivedirectoryobjectid != null &&
                     Azureactivedirectoryobjectid.Equals(other.Azureactivedirectoryobjectid)
                 ) &&
                 (
                     Systemuserid == other.Systemuserid ||
                     Systemuserid != null &&
                     Systemuserid.Equals(other.Systemuserid)
                 ) &&
                 (
                     Ownerid == other.Ownerid ||
                     Ownerid != null &&
                     Ownerid.Equals(other.Ownerid)
                 ));
        }
        public async Task <Guid> Handle(CreateUserCommand request, CancellationToken cancellationToken)
        {
            var user = new User(UserId.Create());

            user.Create(
                Fullname.Create(request.Firstname, request.Lastname),
                Email.Create(request.Email),
                Password.Create(request.PlainPassword));

            await _userRepository.Save(user, cancellationToken);

            return(user.Id.Id);
        }
예제 #23
0
        /// <summary>
        /// Return information about the current Comment instance via the api/info endpoint.
        /// </summary>
        /// <returns>An instance of this class populated with the retrieved data.</returns>
        public Comment Info()
        {
            Things.Info info = Validate(Dispatch.LinksAndComments.Info(Fullname, Subreddit));
            if (info == null ||
                info.Comments == null ||
                info.Comments.Count == 0 ||
                !Fullname.Equals(info.Comments[0].Name))
            {
                throw new RedditControllerException("Unable to retrieve comment data.");
            }

            return(new Comment(Dispatch, info.Comments[0]));
        }
예제 #24
0
        // Fill selected contact text to textbox
        private void cmbContact_SelectionChanged_1(object sender, SelectionChangedEventArgs e)
        {
            btnUpdate.Visibility = Visibility.Visible;
            Fullname fullname = cmbContact.SelectedItem as Fullname;
            Contacts contact  = db.Contacts.Find(fullname.Id);

            if (contact != null)
            {
                txtName.Text    = contact.Name;
                txtSurname.Text = contact.Surname;
                txtPhone.Text   = contact.Phone;
            }
        }
예제 #25
0
        // Full name for Combobox to list from database
        public void fillFullname()
        {
            foreach (Contacts contact in db.Contacts.ToList())
            {
                Fullname fullname = new Fullname
                {
                    Id  = contact.Id,
                    All = contact.Name + " " + contact.Surname + " " + contact.Phone
                };

                cmbContact.Items.Add(fullname);
            }
        }
예제 #26
0
        /// <summary>
        /// Return information about the current SelfPost instance.
        /// </summary>
        /// <returns>An instance of this class populated with the retrieved data.</returns>
        public new SelfPost About()
        {
            Info info = Validate(Dispatch.LinksAndComments.Info(Fullname, Subreddit));

            if (info == null ||
                info.Posts == null ||
                info.Posts.Count == 0 ||
                !Fullname.Equals(info.Posts[0].Name))
            {
                throw new RedditControllerException("Unable to retrieve post data.");
            }

            return(new SelfPost(Dispatch, info.Posts[0]));
        }
        public async Task Should_PassCorrectDetails_When_Calling_Save()
        {
            IReadOnlyCollection <IDomainEvent> eventsReceived = null;
            var streamNameReceived = string.Empty;

            Given(repository =>
            {
                _eventsRepoMock.Setup(r => r.Save(
                                          It.IsAny <IReadOnlyCollection <IDomainEvent> >(),
                                          It.IsAny <string>(),
                                          It.IsAny <CancellationToken>()))
                .Callback <IReadOnlyCollection <IDomainEvent>, string, CancellationToken>((
                                                                                              events,
                                                                                              streamName,
                                                                                              cancellationToken) =>
                {
                    eventsReceived     = events;
                    streamNameReceived = streamName;
                });
            });

            var aggregate = new User(UserId.Create("dev"));
            var fullname  = Fullname.Create("Mark", "Libres");
            var email     = Email.Create("*****@*****.**");
            var password  = Password.Create("secret");


            await WhenAsync(async repository =>
            {
                aggregate.Create(fullname, email, password);
                await repository.Save(aggregate, CancellationToken.None);
                return(Task.CompletedTask);
            });

            Then(repository =>
            {
                eventsReceived.Should()
                .NotBeNull()
                .And
                .HaveCount(1);
                streamNameReceived.Should().Be(aggregate.Id.StreamName);
                aggregate.UncommittedEvents.Should()
                .NotBeNullOrEmpty()
                .And
                .HaveCount(1);
                aggregate.CommittedEvents.Should()
                .BeNullOrEmpty();
            });
        }
예제 #28
0
 private bool Diff(LiveThread compare)
 {
     return(!(Id.Equals(compare.Id) &&
              Description.Equals(compare.Description) &&
              NSFW.Equals(compare.NSFW) &&
              Resources.Equals(compare.Resources) &&
              TotalViews.Equals(compare.TotalViews) &&
              Created.Equals(compare.Created) &&
              Fullname.Equals(compare.Fullname) &&
              IsAnnouncement.Equals(compare.IsAnnouncement) &&
              AnnouncementURL.Equals(compare.AnnouncementURL) &&
              State.Equals(compare.State) &&
              ViewerCount.Equals(compare.ViewerCount) &&
              Icon.Equals(compare.Icon)));
 }
예제 #29
0
        public Person CreatePerson()
        {
            var fullName        = Fullname.Create("Billy", "The", "Goat");
            var idNo            = RSAIdentityNumber.Create("21021112341134");
            var cellNo          = CellphoneNumber.Create("27743389201");
            var emailAddress    = EmailAddress.Create("*****@*****.**");
            var physicalAddress = new Address("4", "Table Mountain", "Cape Town", "7441", "Western Cape", "South Africa");
            var postalAddress   = new Address("4", "Table Mountain", "Cape Town", "7441", "Western Cape", "South Africa");
            var workAddress     = new Address("4", "Table Mountain", "Cape Town", "7441", "Western Cape", "South Africa");
            var money           = new Money(900000, "Coins", "ZAR");

            var person = new Person(fullName, idNo, cellNo, emailAddress, physicalAddress, postalAddress, workAddress, money, false, "Some Stuff About Me", MaritalStatus.Married, Gender.Goat, DateTime.Today);

            return(person);
        }
예제 #30
0
        /// <summary>
        /// Returns a hash code for this instance.
        /// </summary>
        /// <returns>
        /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
        /// </returns>
        public override int GetHashCode()
        {
            int val = Fullname.GetHashCode();

            if (AssemblyName != null)
            {
                val ^= AssemblyName.GetHashCode();
            }
            foreach (var item in TypeArguments)
            {
                val ^= item.GetHashCode();
            }
            val ^= ArrayRanks.Select(x => (int)x).Sum();
            return(base.GetHashCode());
        }