public void mongo_task_entity_update_immediate_test()
        {
            var dateTime = DateTime.Now;
            var timeSpan = new TimeSpan(1, 1, 1);
            var task     = GetMongoTaskEntity(dateTime, timeSpan);

            var repo = new MongoTestDB <MongoTaskEntity>();

            repo.Insert(task);
            var id = task.Id;

            var newTimeSpan = new TimeSpan(3, 3, 3);
            var newDateTime = dateTime.AddDays(-1);
            var newName     = "newMongoTest";

            var dic = new Dictionary <string, object>();

            dic.Add("TaskEntity.StartTime", newTimeSpan);
            dic.Add("TaskStatusEntity.LastRunTime", newDateTime);
            dic.Add("Name", newName);

            repo.Update(p => p.Id == id, dic);

            //var updatedTask = repo.GetAll().First();
            var updatedTask = repo.GetByKey(id);

            updatedTask.TaskEntity.StartTime.Should().Be(newTimeSpan);
            updatedTask.TaskStatusEntity.LastRunTime.Day.Should().Be(dateTime.AddDays(-1).Day);
            updatedTask.Name.Should().Be(newName);
        }
        public void mongo_add_and_update_test()
        {
            var customerRepo = new MongoTestDB <Customer>();

            var customer = CreateCustomer();

            customerRepo.Insert(customer);

            customer.Id.Should().NotBeNull();
            var alreadyAddedCustomer = customerRepo.GetBy(c => c.FirstName == "Bob").Single();

            alreadyAddedCustomer.Should().NotBeNull();
            alreadyAddedCustomer.FirstName.Should().Be(customer.FirstName);
            alreadyAddedCustomer.HomeAddress.Address1.Should().Be(customer.HomeAddress.Address1);
            alreadyAddedCustomer.CreateDate.Should().BeBefore(DateTime.Now);

            alreadyAddedCustomer.Phone = "10110111";
            alreadyAddedCustomer.Email = "*****@*****.**";

            customerRepo.Update(alreadyAddedCustomer);

            var updatedCustomer = customerRepo.GetByKey(customer.Id);

            updatedCustomer.Should().NotBeNull();
            updatedCustomer.Phone.Should().Be(alreadyAddedCustomer.Phone);
            updatedCustomer.Email.Should().Be(alreadyAddedCustomer.Email);
            var isExists = customerRepo.Exists(c => c.HomeAddress.Country == "Alaska");

            isExists.Should().Be(true);
        }
        public void mongo_update_assign_field()
        {
            var customerRepo = new MongoTestDB <Customer>();

            var customer = CreateCustomer();

            customerRepo.Insert(customer);

            var updateFields = new Dictionary <string, object>();

            updateFields.Add("FirstName", "JiaJia");
            updateFields.Add("Phone", "123");

            customerRepo.Update(q => q.Id == customer.Id, updateFields);
            var updatedCustomer = customerRepo.GetByKey(customer.Id);

            updatedCustomer.FirstName.Should().Be("JiaJia");
            updatedCustomer.Phone.Should().Be("123");
        }