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.True( TestDocumentFactory.Create(seed).Equals(randomDocument)); }
private async Task GetAll() { List <TestDocument> testDocuments = (await this.repository.GetAll()).ToList(); Assert.Equal( TestDocumentCount, testDocuments.Count); int seed = this.GetRandomSeed(); TestDocument randomDocument = testDocuments.OrderBy(d => d.Seed).ElementAt(seed); Assert.True( TestDocumentFactory.Create(seed).Equals(randomDocument)); }
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.True( TestDocumentFactory.Create(seed1).Equals(testDocuments.Find(d => d.Seed == seed1))); Assert.True( TestDocumentFactory.Create(seed2).Equals(testDocuments.Find(d => d.Seed == seed2))); }
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.Equal( updatedName, returnedDocument.Name); var updatedDocument = await this.repository.Get(d => d.Seed == seed); Assert.True( updatedDocument.Equals(returnedDocument) && updatedDocument.Equals(randomDocument)); Assert.False( TestDocumentFactory.Create(seed).Equals(updatedDocument)); }