示例#1
0
        public async Task GetReviewShouldReturnNullIfFileNotExists()
        {
            // Arrange
            var    mockFileSystem = new MockFileSystem();
            string path           = Path.Combine(Environment.CurrentDirectory, "data", "donotexist.json");
            IAsyncContentManager contentManager = new FileContentManager(path, mockFileSystem);

            // Act
            Review review = await contentManager.GetReviewAsync(It.IsAny <Guid>());

            // Assert
            Assert.IsNull(review);
        }
示例#2
0
        public async Task GetReviewShouldReturnNullIfFileIsEmpty()
        {
            // Arrange
            var    mockFileSystem = new MockFileSystem();
            var    mockInputFile  = new MockFileData(FileStrings.GetFile("empty"));
            string path           = @"C:\tmp\empty.json";

            mockFileSystem.AddFile(path, mockInputFile);
            IAsyncContentManager contentManager = new FileContentManager(path, mockFileSystem);

            // Act
            Review review = await contentManager.GetReviewAsync(It.IsAny <Guid>());

            // Assert
            Assert.IsNull(review);
        }
示例#3
0
        public void GetReviewShouldThrowExceptionWhenNoMatch()
        {
            // Arrange
            string fileName       = "oneReview";
            var    mockFileSystem = new MockFileSystem();
            var    mockInputFile  = new MockFileData(FileStrings.GetFile(fileName));
            string path           = $@"C:\tmp\{fileName}.json";

            mockFileSystem.AddFile(path, mockInputFile);
            IAsyncContentManager contentManager = new FileContentManager(path, mockFileSystem);
            Guid guid = new Guid("7176da9a-3670-4fe3-8d11-cb19d697620e");

            // Act
            // Assert
            Assert.ThrowsAsync <InvalidOperationException>(async() => await contentManager.GetReviewAsync(guid));
        }
示例#4
0
        public async Task GetReviewShouldReturnReviewIfOnlyMatch(string fileName, string guidStr, ReviewStatus expectedStatus)
        {
            // Arrange
            var    mockFileSystem = new MockFileSystem();
            var    mockInputFile  = new MockFileData(FileStrings.GetFile(fileName));
            string path           = $@"C:\tmp\{fileName}.json";

            mockFileSystem.AddFile(path, mockInputFile);
            IAsyncContentManager contentManager = new FileContentManager(path, mockFileSystem);
            Guid guid = new Guid(guidStr);

            // Act
            Review review = await contentManager.GetReviewAsync(guid);

            // Assert
            Assert.AreEqual(guid, review.Guid);
            Assert.AreEqual(expectedStatus, review.Status);
            Assert.AreEqual(new DateTime(2009, 02, 15), review.StartDate);
            Assert.AreEqual(new DateTime(2009, 02, 15), review.EndDate);
            Assert.IsNotNull(review.Records);
            Assert.IsFalse(review.Records.Any());
        }