Exemple #1
0
        public void TestGetFileCommand()
        {
            // Arrange
            var getFilecommand = new FilesGetCommand(GetFakeApiController(), GetFakeFileRepository(), FileIdConst);

            // Act
            Task <File> getFileTask = getFilecommand.Execute();

            getFileTask.Wait();

            // Assert
            Assert.IsFalse(getFileTask.IsFaulted);
            Assert.IsNotNull(getFileTask.Result);
            _repositoryMock.Verify(m => m.GetAsync(UserIdConst, FileIdConst), Times.Once());
        }
Exemple #2
0
        public void TestGetNotExistFileCommand()
        {
            // Arrange
            var getFilecommand             = new FilesGetCommand(GetFakeApiController(), GetFakeFileRepository(), FileIdNotExistConst);
            AggregateException exception   = null;
            Task <File>        getFileTask = null;

            // Act
            try
            {
                getFileTask = getFilecommand.Execute();
                getFileTask.Wait();
            }
            catch (AggregateException e)
            {
                exception = e;
            }

            // Assert
            Assert.IsNotNull(getFileTask);
            Assert.IsTrue(getFileTask.IsFaulted);
            Assert.IsNotNull(exception);
            Assert.IsInstanceOfType(exception.InnerException, typeof(HttpResponseException));
        }
        public void TestGetNotExistFileCommand()
        {
            // Arrange
            var getFilecommand = new FilesGetCommand(GetFakeApiController(), GetFakeFileRepository(), FileIdNotExistConst);
            AggregateException exception = null;
            Task<File> getFileTask = null;

            // Act
            try
            {
                getFileTask = getFilecommand.Execute();
                getFileTask.Wait();
            }
            catch (AggregateException e)
            {
                exception = e;
            }

            // Assert
            Assert.IsNotNull(getFileTask);
            Assert.IsTrue(getFileTask.IsFaulted);
            Assert.IsNotNull(exception);
            Assert.IsInstanceOfType(exception.InnerException, typeof (HttpResponseException));
        }
        public void TestGetFileCommand()
        {
            // Arrange
            var getFilecommand = new FilesGetCommand(GetFakeApiController(), GetFakeFileRepository(), FileIdConst);

            // Act
            Task<File> getFileTask = getFilecommand.Execute();
            getFileTask.Wait();

            // Assert
            Assert.IsFalse(getFileTask.IsFaulted);
            Assert.IsNotNull(getFileTask.Result);
            _repositoryMock.Verify(m => m.GetAsync(UserIdConst, FileIdConst), Times.Once());
        }