Пример #1
0
        public void GetHelloMessageTest()
        {
            Message target = new Message();

            DateTime     wedate       = new DateTime(2018, 08, 25, 16, 0, 0);
            FakeDateTime fakeDateTime = new FakeDateTime(wedate);

            target.DateTimeProvider = fakeDateTime;

            FakeName fakeName = new FakeName("Marie");

            target.NameProvider = fakeName;

            string result = target.GetHelloMessage();

            Assert.AreEqual(result, "Bon weekend ! Marie");

            fakeDateTime.DateToReturn = new DateTime(2018, 08, 22, 16, 0, 0);
            result = target.GetHelloMessage();
            Assert.AreEqual(result, "Bon après-midi Marie");

            fakeDateTime.DateToReturn = new DateTime(2018, 08, 22, 9, 0, 0);
            result = target.GetHelloMessage();
            Assert.AreEqual(result, "Bonjour Marie");

            fakeDateTime.DateToReturn = new DateTime(2018, 08, 22, 20, 0, 0);
            result = target.GetHelloMessage();
            Assert.AreEqual(result, "Bonsoir Marie");
        }
Пример #2
0
        public void SeedDB()
        {
            using (var db = new LiteDatabase(Constants.DB_NAME))
            {
                //clean up
                IEnumerable <string> collectionNames = db.GetCollectionNames().ToList();
                foreach (string collectionName in collectionNames)
                {
                    db.DropCollection(collectionName);
                }
            }

            //setup test data
            Employee nextMgr = new Employee()
            {
                Id = Guid.Empty
            };

            for (int i = 0; i < 99; i++)
            {
                FakeName fname                = GetAName();
                DateTime onboardDate          = DateTime.Now.AddMonths(random.Next(-100, -12));
                DateTime recentPerfReviewDate = new DateTime(DateTime.Now.Year - 1, onboardDate.Month, 1);
                Employee theNextMgr           = EmployeeFactory.CreateEmployee(fname.FirstName, fname.LastName, (Gender)GetValue(genders), fname.Email, nextMgr, (Title)GetValue(titles), (Level)GetValue(levels), random.Next(50000, 200000), random.Next(0, 10000), onboardDate);
                HistoryFactory.CreateHistory(theNextMgr, nextMgr, (Title)GetValue(titles), (Level)GetValue(levels), random.Next(50000, 200000), random.Next(0, 10000), ActionType.ANNUAL_PERFORMANCE_REVIEW, recentPerfReviewDate);
                nextMgr = theNextMgr;
            }
        }
Пример #3
0
 public FakeCommunityMember()
 {
     RelatedId  = RandomHelper.Next(10000);
     MemberName = FakeName.MakeFakeUserName();
     Image      = FakeImage.MakeFakeImage();
     JoinTime   = RandomHelper.Time();
 }
Пример #4
0
 public FakeTopicReply(int topicId, int replyId)
 {
     ReplyId          = replyId;
     TopicId          = topicId;
     ReplyMemberId    = RandomHelper.Next(10000);
     ReplyMemberName  = FakeName.MakeFakeUserName();
     ReplyMemberImage = FakeImage.MakeFakeImage();
     ReplyTime        = RandomHelper.Time();
     Content          = FakeContent.MakeContent();
 }
Пример #5
0
        static void Main(string[] args)
        {
            Console.OutputEncoding = Encoding.UTF8;
            //StudentStore store = new StudentStore();
            //store.GetAllStudent();
            List <StudentStore> Store = new List <StudentStore>();
            var name = new FakeName();
            var age  = new FakeAge();
            var tel  = new FakeTel();
            List <Tuple <string, string> > Student = new List <Tuple <string, string> >();

            for (int i = 0; i < 10; i++)
            {
                Store.Add(new StudentStore()
                {
                    Name = name.generator(),
                    Age  = age.generator(),
                    Tel  = tel.generator()
                });
            }
            Console.WriteLine("Danh sách ngẫu nhiên 10 sinh viên với các thông tin Fullname, Age, Tel");
            foreach (var s in Store)
            {
                s.Xuat();
                if (s.Age > 18 && s.Age < 30)
                {
                    Student.Add(new Tuple <string, string>(s.Name, s.Tel));
                }
            }
            Console.WriteLine("Danh sách sinh viên (chỉ gồm tên và số điện thoại) có độ tuổi > 18 và < 30");
            int length = Student.Count;

            if (length == 0)
            {
                Console.WriteLine("Không có dữ liệu hợp lệ!");
            }
            else
            {
                foreach (var e in Student)
                {
                    Console.WriteLine($"\tFullname: {e.Item1}");
                    Console.WriteLine($"\tTel: {e.Item2}");
                    Console.WriteLine("---------------------------------");
                }
            }
        }
Пример #6
0
 public FakeUserInfo(int id)
 {
     Id            = id;
     JobNumber     = RandomHelper.Next().ToString();
     Name          = FakeName.MakeFakeUserName();
     EntryTime     = RandomHelper.Bool() ? DateTime.Now.Subtract(TimeSpan.FromDays(RandomHelper.Next(2000))) : DateTime.Now.Subtract(TimeSpan.FromHours(RandomHelper.Next(1000)));
     Rank          = (int)DateTime.Now.Subtract(EntryTime).TotalDays * 2 + RandomHelper.Next(1000);
     Sex           = RandomHelper.Bool() ? "男" : "女";
     LastLoginTime = DateTime.Now;
     NickName      = FakeName.MakeFakeUserName();
     GroupName     = FakeName.MakeFakeGroupName();
     for (int i = 0; i < RandomHelper.Next(2, 6); i++)
     {
         Interesting.Add(FakeName.MakeFakeTag());
     }
     Signature = "yooooooooooo";
     Image     = FakeImage.MakeFakeImage();
 }
Пример #7
0
        public FakeCommunityInfo()
        {
            CommunityId      = RandomHelper.Next(23432);
            ParentId         = RandomHelper.Bool() ? RandomHelper.Next(234) : 0;
            ParentName       = ParentId > 0 ? FakeName.MakeFakeGroupName() : "";
            Name             = FakeName.MakeFakeCommunityName();
            Image            = FakeImage.MakeFakeImage();
            MasterId         = RandomHelper.Next(23432);
            MemberCount      = RandomHelper.Next(546);
            CreateTime       = RandomHelper.Time();
            Description      = FakeContent.MakeDescription();
            LastActivityTime = RandomHelper.Time();
            CloseTime        = RandomHelper.Bool() ? RandomHelper.Time() : DateTime.MaxValue;

            int tagCount = RandomHelper.Next(10);

            for (int i = 0; i < tagCount; i++)
            {
                Tags.Add(new TagModel());
            }
        }
Пример #8
0
 public FakeTag()
 {
     TagId     = RandomHelper.Next(35345);
     TagName   = FakeName.MakeFakeTag();
     HotDegree = RandomHelper.Next(5000);
 }