当前位置: 首页>>代码示例>>C#>>正文


C# ExpectedResult类代码示例

本文整理汇总了C#中ExpectedResult的典型用法代码示例。如果您正苦于以下问题:C# ExpectedResult类的具体用法?C# ExpectedResult怎么用?C# ExpectedResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ExpectedResult类属于命名空间,在下文中一共展示了ExpectedResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Update_Should_Update_A_ExpectedResult

 public void Update_Should_Update_A_ExpectedResult() 
 {
     _repository
          .Setup(it => it.Update(It.IsAny<Int32>(), It.IsAny<String>(), It.IsAny<Int32?>(), It.IsAny<Int32>(), It.IsAny<Int32>()))
          .Callback<Int32, String, Int32?, Int32, Int32>((testId, expectedValue, assertTypeId, resultIndex, id) => 
     { 
          var tExpectedResult = _repositoryList.Find(x => x.Id==id);
          tExpectedResult.TestId = testId; 
          tExpectedResult.ExpectedValue = expectedValue; 
          tExpectedResult.AssertTypeId = assertTypeId; 
          tExpectedResult.ResultIndex = resultIndex; 
     });
     var tempExpectedResult = _repositoryList.Find(x => x.Id==id);
     var testExpectedResult = new ExpectedResult {
          Id = tempExpectedResult.Id, 
          TestId = tempExpectedResult.TestId, 
          ExpectedValue = tempExpectedResult.ExpectedValue, 
          AssertTypeId = tempExpectedResult.AssertTypeId, 
          ResultIndex = tempExpectedResult.ResultIndex};
     
     //TODO change something on testExpectedResult
     //testExpectedResult.oldValue = newValue; 
     _target.Update(testExpectedResult);
     //Assert.AreEqual(newValue, _repositoryList.Find(x => x.Id==1).oldValue);
     //TODO fail until we update the test above
     Assert.Fail();
 }
开发者ID:leloulight,项目名称:LucentDb,代码行数:27,代码来源:ExpectedResultWebAPITest.cs

示例2: Edit

 public ActionResult Edit(int id, ExpectedResult expectedResult)
 {
     try
     {
         _dbExpectedResultRepository.Update(expectedResult);
         return RedirectToAction("Index");
     }
     catch
     {
         return View(expectedResult);
     }
 }
开发者ID:leloulight,项目名称:LucentDb,代码行数:12,代码来源:ExpectedResultController.cs

示例3: Create

 public ActionResult Create(ExpectedResult expectedResult)
 {
     try
     {
         _dbExpectedResultRepository.Insert(expectedResult);
         return RedirectToAction("Index");
     }
     catch
     {
         return View(expectedResult);
     }
 }
开发者ID:leloulight,项目名称:LucentDb,代码行数:12,代码来源:ExpectedResultController.cs

示例4: Update

 public void Update(int testId, int? expectedResultTypeId, int? assertTypeId, string expectedValue,
     int resultIndex, int id)
 {
     using (var client = new HttpClient(_messageHandler, false))
     {
         client.BaseAddress = new Uri(_baseAddress);
         client.DefaultRequestHeaders.Accept.Clear();
         client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
         var expectedResult = new ExpectedResult
         {
             TestId = testId,
             ExpectedResultTypeId = expectedResultTypeId,
             AssertTypeId = assertTypeId,
             ExpectedValue = expectedValue,
             ResultIndex = resultIndex,
             Id = id
         };
         var response = client.PutAsync(UrlBase, expectedResult, new JsonMediaTypeFormatter()).Result;
         response.EnsureSuccessStatusCode();
     }
 }
开发者ID:leloulight,项目名称:LucentDb,代码行数:21,代码来源:WebApiExpectedResultRepository.cs

示例5: TestValidateDirectory

		////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>	Tests the validation of a directory. </summary>
		///
		/// <exception cref="NotSupportedException">
		/// 	Thrown when the requested operation is not supported.
		/// </exception>
		///
		/// <param name="definitionFile">	The validator definition file. </param>
		/// <param name="path">			 	Full pathname of the directory to validate. </param>
		/// <param name="expectedResult">	The expected validation result. </param>
		///
		/// <returns>	true if the test passes, false if the test fails. </returns>
		private bool TestValidateDirectory(string definitionFile, string path, ExpectedResult expectedResult)
		{
			using (var xmlReader = XmlReader.Create(definitionFile))
			{
				var definition = PathValidator.DeserializeDefinition(xmlReader);
				var validator = new PathValidator();

				validator.Validate(definition, path);

				switch (expectedResult)
				{
					case ExpectedResult.Valid:
						return (validator.ErrorMessages.Count == 0) && (validator.WarningMessages.Count == 0);
					case ExpectedResult.Warning:
						return (validator.ErrorMessages.Count == 0) && (validator.WarningMessages.Count > 0);
					case ExpectedResult.Error:
						return (validator.ErrorMessages.Count > 0) && (validator.WarningMessages.Count == 0);
					default:
						throw new NotSupportedException("Unknown result type");
				}
			}
		}
开发者ID:guardian2433,项目名称:open-sauce,代码行数:34,代码来源:Validator.Tests.cs

示例6: TestBatchSplittingBySizeWithErrorsOrdered

        public void TestBatchSplittingBySizeWithErrorsOrdered()
        {
            _collection.Drop();

            var documents = new BsonDocument[8];
            for (var i = 0; i < 6; i++)
            {
                documents[i] = new BsonDocument { { "_id", i }, { "a", new string('x', 4 * 1024 * 1024) } };
            }
            documents[6] = new BsonDocument("_id", 0); // will fail
            documents[7] = new BsonDocument("_id", 100);

            var bulk = _collection.InitializeOrderedBulkOperation();
            for (var i = 0; i < 8; i++)
            {
                bulk.Insert(documents[i]);
            }
            var exception = Assert.Throws<BulkWriteException>(() => { bulk.Execute(); });
            var result = exception.Result;

            Assert.IsNull(exception.WriteConcernError);
            Assert.AreEqual(1, exception.WriteErrors.Count);
            var writeError = exception.WriteErrors[0];
            Assert.AreEqual(6, writeError.Index);
            Assert.AreEqual(11000, writeError.Code);

            var expectedResult = new ExpectedResult
            {
                InsertedCount = 6,
                ProcessedRequestsCount = 7,
                RequestCount = 8
            };
            CheckExpectedResult(expectedResult, result);

            var expectedDocuments = documents.Take(6);
            Assert.That(_collection.FindAll(), Is.EqualTo(expectedDocuments));
        }
开发者ID:niemyjski,项目名称:mongo-csharp-driver,代码行数:37,代码来源:BulkWriteOperationTests.cs

示例7: TestRemoveWithEmptyQueryRemovesAllDocuments

        public void TestRemoveWithEmptyQueryRemovesAllDocuments(bool ordered)
        {
            _collection.Drop();
            _collection.Insert(new BsonDocument("key", 1));
            _collection.Insert(new BsonDocument("key", 1));

            var bulk = InitializeBulkOperation(_collection, ordered);
            bulk.Find(new QueryDocument()).Remove();
            var result = bulk.Execute();

            var expectedResult = new ExpectedResult { DeletedCount = 2 };
            CheckExpectedResult(expectedResult, result);

            Assert.AreEqual(0, _collection.Count());
        }
开发者ID:niemyjski,项目名称:mongo-csharp-driver,代码行数:15,代码来源:BulkWriteOperationTests.cs

示例8: TestRemoveMultiple

        public void TestRemoveMultiple(bool ordered)
        {
            _collection.Drop();

            var documents = new BsonDocument[]
            {
                new BsonDocument("_id", 1),
                new BsonDocument("_id", 2),
                new BsonDocument("_id", 3)
            };
            _collection.Insert(documents[0]);
            _collection.Insert(documents[1]);
            _collection.Insert(documents[2]);

            var bulk = InitializeBulkOperation(_collection, ordered);
            bulk.Find(Query.EQ("_id", 1)).RemoveOne();
            bulk.Find(Query.EQ("_id", 3)).RemoveOne();
            var result = bulk.Execute();

            var expectedResult = new ExpectedResult { DeletedCount = 2, RequestCount = 2 };
            CheckExpectedResult(expectedResult, result);

            var expectedDocuments = new[] { documents[1] };
            Assert.That(_collection.FindAll(), Is.EquivalentTo(expectedDocuments));
        }
开发者ID:niemyjski,项目名称:mongo-csharp-driver,代码行数:25,代码来源:BulkWriteOperationTests.cs

示例9: TestOrderedBatchWithErrors

        public void TestOrderedBatchWithErrors()
        {
            _collection.Drop();
            _collection.CreateIndex(IndexKeys.Ascending("a"), IndexOptions.SetUnique(true));

            var bulk = _collection.InitializeOrderedBulkOperation();
            bulk.Insert(new BsonDocument { { "b", 1 }, { "a", 1 } });
            bulk.Find(Query.EQ("b", 2)).Upsert().UpdateOne(Update.Set("a", 1)); // will fail
            bulk.Find(Query.EQ("b", 3)).Upsert().UpdateOne(Update.Set("a", 2));
            bulk.Find(Query.EQ("b", 2)).Upsert().UpdateOne(Update.Set("a", 1));
            bulk.Insert(new BsonDocument { { "b", 4 }, { "a", 3 } });
            bulk.Insert(new BsonDocument { { "b", 5 }, { "a", 1 } });
            var exception = Assert.Throws<BulkWriteException>(() => { bulk.Execute(); });
            var result = exception.Result;

            var expectedResult = new ExpectedResult
            {
                InsertedCount = 1,
                ProcessedRequestsCount = 2,
                RequestCount = 6,
                IsModifiedCountAvailable = _primary.Supports(FeatureId.WriteCommands)
            };
            CheckExpectedResult(expectedResult, result);

            var upserts = result.Upserts;
            Assert.AreEqual(0, upserts.Count);

            Assert.IsNull(exception.WriteConcernError);
            Assert.AreEqual(4, exception.UnprocessedRequests.Count);

            var writeErrors = exception.WriteErrors;
            Assert.AreEqual(1, writeErrors.Count);
            Assert.AreEqual(1, writeErrors[0].Index);
            Assert.AreEqual(11000, writeErrors[0].Code);

            var expectedDocuments = new BsonDocument[]
            {
                new BsonDocument { { "b", 1 }, { "a", 1 } }
            };
            Assert.That(_collection.FindAll().SetFields(Fields.Exclude("_id")), Is.EquivalentTo(expectedDocuments));
        }
开发者ID:niemyjski,项目名称:mongo-csharp-driver,代码行数:41,代码来源:BulkWriteOperationTests.cs

示例10: TestW0DoesNotReportErrors

        public void TestW0DoesNotReportErrors(bool ordered)
        {
            _collection.Drop();

            var documents = new[]
            {
                new BsonDocument("_id", 1),
                new BsonDocument("_id", 1)
            };

            var bulk = InitializeBulkOperation(_collection, ordered);
            bulk.Insert(documents[0]);
            bulk.Insert(documents[1]);
            var result = bulk.Execute(WriteConcern.Unacknowledged);

            var expectedResult = new ExpectedResult { IsAcknowledged = false, RequestCount = 2 };
            CheckExpectedResult(expectedResult, result);

            var expectedDocuments = new[] { documents[0] };
            Assert.That(_collection.FindAll(), Is.EquivalentTo(expectedDocuments));
        }
开发者ID:niemyjski,项目名称:mongo-csharp-driver,代码行数:21,代码来源:BulkWriteOperationTests.cs

示例11: TestUpsertWithMultipleMatchingDocuments

        public void TestUpsertWithMultipleMatchingDocuments(bool ordered)
        {
            _collection.Drop();
            _collection.Insert(new BsonDocument { { "_id", 1 }, { "x", 1 } });
            _collection.Insert(new BsonDocument { { "_id", 2 }, { "x", 1 } });

            var bulk = InitializeBulkOperation(_collection, ordered);
            var query = Query.EQ("x", 1);
            var update = Update.Set("x", 2);
            bulk.Find(query).Upsert().Update(update);
            var result = bulk.Execute();

            var expectedResult = new ExpectedResult
            {
                MatchedCount = 2,
                ModifiedCount = 2,
                IsModifiedCountAvailable = _primary.Supports(FeatureId.WriteCommands)
            };
            CheckExpectedResult(expectedResult, result);

            var expectedDocuments = new BsonDocument[]
            {
                new BsonDocument { { "_id", 1 }, { "x", 2 } },
                new BsonDocument { { "_id", 2 }, { "x", 2 } }
            };
            Assert.That(_collection.FindAll(), Is.EquivalentTo(expectedDocuments));
        }
开发者ID:niemyjski,项目名称:mongo-csharp-driver,代码行数:27,代码来源:BulkWriteOperationTests.cs

示例12: TestUpsertUpdateOneOnlyAffectsOneMatchingDocument

        public void TestUpsertUpdateOneOnlyAffectsOneMatchingDocument(bool ordered)
        {
            _collection.Drop();
            _collection.Insert(new BsonDocument("key", 1));
            _collection.Insert(new BsonDocument("key", 1));

            var bulk = InitializeBulkOperation(_collection, ordered);
            bulk.Find(Query.EQ("key", 1)).Upsert().UpdateOne(Update.Set("x", 1));
            var result = bulk.Execute();

            var expectedResult = new ExpectedResult
            {
                MatchedCount = 1,
                ModifiedCount = 1,
                IsModifiedCountAvailable = _primary.Supports(FeatureId.WriteCommands)
            };
            CheckExpectedResult(expectedResult, result);

            var expectedDocuments = new BsonDocument[]
            {
                new BsonDocument { { "key", 1 }, { "x", 1 } },
                new BsonDocument { { "key", 1 } }
            };
            Assert.That(_collection.FindAll().SetFields(Fields.Exclude("_id")), Is.EquivalentTo(expectedDocuments));
        }
开发者ID:niemyjski,项目名称:mongo-csharp-driver,代码行数:25,代码来源:BulkWriteOperationTests.cs

示例13: TestUnorderedBatchWithErrors

        public void TestUnorderedBatchWithErrors()
        {
            _collection.Drop();
            _collection.CreateIndex(IndexKeys.Ascending("a"), IndexOptions.SetUnique(true));

            var bulk = _collection.InitializeUnorderedBulkOperation();
            bulk.Insert(new BsonDocument { { "b", 1 }, { "a", 1 } });
            bulk.Find(Query.EQ("b", 2)).Upsert().UpdateOne(Update.Set("a", 1));
            bulk.Find(Query.EQ("b", 3)).Upsert().UpdateOne(Update.Set("a", 2));
            bulk.Find(Query.EQ("b", 2)).Upsert().UpdateOne(Update.Set("a", 1));
            bulk.Insert(new BsonDocument { { "b", 4 }, { "a", 3 } });
            bulk.Insert(new BsonDocument { { "b", 5 }, { "a", 1 } });
            var exception = Assert.Throws<BulkWriteException>(() => { bulk.Execute(); });
            var result = exception.Result;

            var expectedResult = new ExpectedResult
            {
                InsertedCount = 2,
                RequestCount = 6,
                UpsertsCount = 1,
                IsModifiedCountAvailable = _primary.Supports(FeatureId.WriteCommands)
            };
            CheckExpectedResult(expectedResult, result);

            var upserts = result.Upserts;
            Assert.AreEqual(1, upserts.Count);
            Assert.IsInstanceOf<BsonObjectId>(upserts[0].Id);
            Assert.AreEqual(2, upserts[0].Index);

            Assert.IsNull(exception.WriteConcernError);
            Assert.AreEqual(0, exception.UnprocessedRequests.Count);

            var writeErrors = exception.WriteErrors;
            Assert.AreEqual(3, writeErrors.Count);
            Assert.AreEqual(1, writeErrors[0].Index);
            Assert.AreEqual(3, writeErrors[1].Index);
            Assert.AreEqual(5, writeErrors[2].Index);
            Assert.IsTrue(writeErrors.All(e => e.Code == 11000));

            var expectedDocuments = new BsonDocument[]
            {
                new BsonDocument { { "b", 1 }, { "a", 1 } },                   
                _primary.BuildInfo.Version < new Version(2, 6, 0) ?
                    new BsonDocument { { "a", 2 }, { "b", 3 } } : // servers prior to 2.6 rewrite field order on update
                    new BsonDocument { { "b", 3 }, { "a", 2 } },
                new BsonDocument { { "b", 4 }, { "a", 3 } }
            };
            Assert.That(_collection.FindAll().SetFields(Fields.Exclude("_id")), Is.EquivalentTo(expectedDocuments));
        }
开发者ID:niemyjski,项目名称:mongo-csharp-driver,代码行数:49,代码来源:BulkWriteOperationTests.cs

示例14: TestInsertOneDocument

        public void TestInsertOneDocument(bool ordered)
        {
            _collection.Drop();

            var document = new BsonDocument("_id", 1);

            var bulk = InitializeBulkOperation(_collection, ordered);
            bulk.Insert(document);
            var result = bulk.Execute();

            var expectedResult = new ExpectedResult { InsertedCount = 1 };
            CheckExpectedResult(expectedResult, result);

            Assert.That(_collection.FindAll(), Is.EquivalentTo(new[] { document }));
        }
开发者ID:niemyjski,项目名称:mongo-csharp-driver,代码行数:15,代码来源:BulkWriteOperationTests.cs

示例15: TestInsertMultipleDocuments

        public void TestInsertMultipleDocuments(bool ordered)
        {
            _collection.Drop();

            var documents = new BsonDocument[]
            {
                new BsonDocument("_id", 1),
                new BsonDocument("_id", 2),
                new BsonDocument("_id", 3)
            };

            var bulk = InitializeBulkOperation(_collection, ordered);
            bulk.Insert(documents[0]);
            bulk.Insert(documents[1]);
            bulk.Insert(documents[2]);
            var result = bulk.Execute();

            var expectedResult = new ExpectedResult { InsertedCount = 3, RequestCount = 3 };
            CheckExpectedResult(expectedResult, result);

            Assert.That(_collection.FindAll(), Is.EquivalentTo(documents));
        }
开发者ID:niemyjski,项目名称:mongo-csharp-driver,代码行数:22,代码来源:BulkWriteOperationTests.cs


注:本文中的ExpectedResult类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。