private async Task Update() { var seed = this.GetRandomSeed(); var randomDocument = await this.repository.Get(d => d.Seed == seed); string updatedName = "Different name"; randomDocument.Name = updatedName; var returnedDocument = await this.repository.Update(randomDocument); Assert.AreEqual( updatedName, returnedDocument.Name, "Document name has not been updated"); var updatedDocument = await this.repository.Get(d => d.Seed == seed); Assert.IsTrue( updatedDocument.Equals(returnedDocument) && updatedDocument.Equals(randomDocument), "Updated document does not equal to chosen manually updated document"); Assert.IsFalse( TestDocumentFactory.Create(seed).Equals(updatedDocument), "Document has not been updated"); }
private async Task Create() { for (int i = 0; i < TestDocumentCount; i++) { await this.repository.Create( TestDocumentFactory.Create(i)); } }
private async Task GetPredicate() { var seed = this.GetRandomSeed(); var randomDocument = await this.repository.Get(d => d.Seed == seed); Assert.IsTrue( TestDocumentFactory.Create(seed).Equals(randomDocument), $"Test document with seed {seed} is invalid"); }
private async Task GetAll() { List <TestDocument> testDocuments = (await this.repository.GetAll()).ToList(); Assert.AreEqual( TestDocumentCount, testDocuments.Count, $"Collection does not contain {TestDocumentCount} documents"); int seed = this.GetRandomSeed(); TestDocument randomDocument = testDocuments.OrderBy(d => d.Seed).ElementAt(seed); Assert.IsTrue( TestDocumentFactory.Create(seed).Equals(randomDocument), $"Test document on index {seed} is invalid"); }
private async Task GetWhere() { var seed1 = this.GetRandomSeed(); var seed2 = this.GetRandomSeed(); List <TestDocument> testDocuments = (await this.repository .GetWhere(d => d.Seed == seed1 || d.Seed == seed2)) .ToList() .OrderBy(d => d.Seed) .ToList(); Assert.IsTrue( TestDocumentFactory.Create(seed1).Equals(testDocuments.Find(d => d.Seed == seed1)), $"Test document with seed {seed1} is invalid"); Assert.IsTrue( TestDocumentFactory.Create(seed2).Equals(testDocuments.Find(d => d.Seed == seed2)), $"Test document with seed {seed2} is invalid"); }