Created
February 8, 2011 01:59
-
-
Save chrisnicola/815701 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class when_an_array_is_updated_internally : mongo_repository_context<CategoryModel> | |
{ | |
static CategoryModel model = new CategoryModel { Name = "Test", FeatureTypes = new[] { | |
new FeatureTypeModel{ Name = "feature1", DefaultValue = "Test1" }, | |
new FeatureTypeModel{ Name = "feature2", DefaultValue = "Test2" }, | |
}}; | |
Establish context = () => { | |
InternalCollection.Save(model); | |
cursor = InternalCollection.Find(Query.EQ("_id", "Test")); | |
}; | |
Because of = () => _result = cursor.Collection.Update( | |
new QueryDocument{{"FeatureTypes.Name", "feature2" }}, | |
Update.SetWrapped("FeatureTypes.$.DefaultValue", "Test3")); | |
It should_not_return_an_error = () => _result.ErrorMessage.ShouldBeEmpty(); | |
It should_update_one_document = () => _result.DocumentsAffected.ShouldEqual(1); | |
It should_updated_the_default_value_of_the_second_feature = () => | |
((string)model.FeatureTypes[1].DefaultValue).ShouldEqual("Test3"); | |
static SafeModeResult _result; | |
static MongoCursor<CategoryModel> cursor; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment