Exemple #1
0
        public void AddNullBabyToBabyListShouldThrowArgumentNullException()
        {
            Baby b = null;

            BabyList babies = new BabyList();

            babies.AddBaby(b);
        }
Exemple #2
0
        public void AddBabyUpdatesList()
        {
            DateTime endDate   = new DateTime(2017, 9, 19);
            DateTime startDate = new DateTime(2016, 10, 19);
            Baby     b         = new Baby(5, "joe", "bloggs", startDate, endDate, "main street", "001243235", "ann bloggs");
            BabyList babyList  = new BabyList();

            babyList.AddBaby(b);
            CollectionAssert.Contains(babyList.Babies, b);
        }
Exemple #3
0
        //람다나 제네릭하게 만들고 싶지만 시간이 없으니...
        //이 프로젝트에 의존적인 부분.
        //설정한 필터에 대한 데이터를 받아온다.
        //비동기로.
        public async Task <BabyList> GetResult()
        {
            BabyList returnList = new BabyList();
            //FilterDefinition<BsonDocument> DoNothingFilter = "{}";
            var collection = m_mongoDatabase.GetCollection <BsonDocument>("nationalBabyName");


            using (IAsyncCursor <BsonDocument> cursor = await collection.FindAsync(m_filter))
            {
                while (cursor.MoveNext())
                {
                    IEnumerable <BsonDocument> batch = cursor.Current;
                    foreach (BsonDocument document in batch)
                    {
                        string name = null;

                        int id = 0;
                        if (document["Id"].IsNumeric == true)
                        {
                            id = document["Id"].AsInt32;
                        }

                        if (document["Name"].IsString == true)
                        {
                            name = document["Name"].AsString;
                        }

                        int year = 0;

                        if (document["Year"].IsNumeric == true)
                        {
                            year = document["Year"].AsInt32;
                        }
                        int count = 0;

                        if (document["Count"].IsNumeric == true)
                        {
                            count = document["Count"].AsInt32;
                        }

                        string gender = null;

                        if (document["Gender"].IsString == true)
                        {
                            gender = document["Gender"].AsString;
                        }

                        var info = new BabyNameInfo();

                        info.Name   = name;
                        info.Year   = year;
                        info.Gender = gender;
                        info.Count  = count;

                        returnList.Add(info);
                    }
                }
            }

            return(returnList);
            // 부탁받은거 호출해주기
        }