public async Task TestAddOrUpdateDocument_DocumentConfigurationDoesNotExist() { var configuration = new SimpleEntityConfiguration(); var id = 1; var documentTypeName = configuration.GetDocumentTypeName(); var message = String.Format("The document configuration for the type [{0}] was not found.", typeof(SimpleEntity)); indexService.Setup(x => x.GetDocumentConfiguration <SimpleEntity>()).Returns(default(SimpleEntityConfiguration)); Action a = () => service.AddOrUpdateDocument(id); Func <Task> f = () => { return(service.AddOrUpdateDocumentAsync(id)); }; a.ShouldThrow <NotSupportedException>().WithMessage(message); f.ShouldThrow <NotSupportedException>().WithMessage(message); }
public async Task TestAddOrUpdateDocument_DocumentDoesNotExist() { var configuration = new SimpleEntityConfiguration(); var id = 1; var documentTypeName = configuration.GetDocumentTypeName(); var message = String.Format("The {0} document with Id {1} was not found.", documentTypeName, id); indexService.Setup(x => x.GetDocumentConfiguration <SimpleEntity>()).Returns(configuration); Action a = () => service.AddOrUpdateDocument(id); Func <Task> f = () => { return(service.AddOrUpdateDocumentAsync(id)); }; a.ShouldThrow <ModelNotFoundException>().WithMessage(message); f.ShouldThrow <ModelNotFoundException>().WithMessage(message); }