Beispiel #1
0
        public void ThrowsExceptionWhenContextIsNull()
        {
            // Arrange
            const int request = 3;
            var       sut     = new TaskGenerator();

            // Act & assert
            Assert.Throws <ArgumentNullException>(() => sut.Create(request, null));
        }
        public void ThrowsExceptionWhenContextIsNull()
        {
            // Fixture setup
            const int request = 3;
            var       sut     = new TaskGenerator();

            // Exercise system and verify outcome
            Assert.Throws <ArgumentNullException>(() => sut.Create(request, null));
            // Teardown
        }
Beispiel #3
0
        public void ReturnsNoSpecimenWhenRequestIsNull()
        {
            // Arrange
            var context = new SpecimenContext(new Fixture());
            var sut     = new TaskGenerator();
            // Act
            var result = sut.Create(null, context);

            // Assert
            Assert.IsType <NoSpecimen>(result);
        }
Beispiel #4
0
        public void CreatedGenericTasksAreMarkedAsComplete()
        {
            // Arrange
            var request = typeof(Task <int>);
            var context = new SpecimenContext(new Fixture());
            var sut     = new TaskGenerator();
            // Act
            var task = (Task <int>)sut.Create(request, context);

            // Assert
            Assert.Equal(TaskStatus.RanToCompletion, task.Status);
        }
Beispiel #5
0
        public void CreatesGenericTasks()
        {
            // Arrange
            var request = typeof(Task <int>);
            var context = new SpecimenContext(new Fixture());
            var sut     = new TaskGenerator();
            // Act
            var result = sut.Create(request, context);

            // Assert
            Assert.IsType <Task <int> >(result);
        }
Beispiel #6
0
        public void ReturnsNoSpecimenForUnknownGenericTaskRequests()
        {
            // Arrange
            var request = typeof(CustomGenericTask <int>);
            var context = new SpecimenContext(new Fixture());
            var sut     = new TaskGenerator();
            // Act
            var result = sut.Create(request, context);

            // Assert
            Assert.IsType <NoSpecimen>(result);
        }
Beispiel #7
0
        public void ReturnsNoSpecimenForNonTaskTypeRequests()
        {
            // Arrange
            var request = typeof(string);
            var context = new SpecimenContext(new Fixture());
            var sut     = new TaskGenerator();
            // Act
            var result = sut.Create(request, context);

            // Assert
            Assert.IsType <NoSpecimen>(result);
        }
Beispiel #8
0
        public void CreatesNonGenericTasks()
        {
            // Arrange
            var request = typeof(Task);
            var context = new SpecimenContext(new Fixture());
            var sut     = new TaskGenerator();
            // Act
            var result = sut.Create(request, context);

            // Assert
            Assert.IsAssignableFrom <Task>(result);
        }
        public void ReturnsNoSpecimenWhenRequestIsNull()
        {
            // Fixture setup
            var context = new SpecimenContext(new Fixture());
            var sut     = new TaskGenerator();
            // Exercise system
            var result = sut.Create(null, context);

            // Verify outcome
            Assert.IsType <NoSpecimen>(result);
            // Teardown
        }
        public void CreatedGenericTasksAreMarkedAsComplete()
        {
            // Fixture setup
            var request = typeof(Task <int>);
            var context = new SpecimenContext(new Fixture());
            var sut     = new TaskGenerator();
            // Exercise system
            var task = (Task <int>)sut.Create(request, context);

            // Verify outcome
            Assert.Equal(TaskStatus.RanToCompletion, task.Status);
            // Teardown
        }
        public void CreatesGenericTasks()
        {
            // Fixture setup
            var request = typeof(Task <int>);
            var context = new SpecimenContext(new Fixture());
            var sut     = new TaskGenerator();
            // Exercise system
            var result = sut.Create(request, context);

            // Verify outcome
            Assert.IsType <Task <int> >(result);
            // Teardown
        }
        public void ReturnsNoSpecimenForUnknownGenericTaskRequests()
        {
            // Fixture setup
            var request = typeof(CustomGenericTask <int>);
            var context = new SpecimenContext(new Fixture());
            var sut     = new TaskGenerator();
            // Exercise system
            var result = sut.Create(request, context);

            // Verify outcome
            Assert.IsType <NoSpecimen>(result);
            // Teardown
        }
        public void ReturnsNoSpecimenForNonTypeRequests()
        {
            // Fixture setup
            const int request = 3;
            var       context = new SpecimenContext(new Fixture());
            var       sut     = new TaskGenerator();
            // Exercise system
            var result = sut.Create(request, context);

            // Verify outcome
            Assert.IsType <NoSpecimen>(result);
            // Teardown
        }
Beispiel #14
0
        public void ResultOfGenericTasksIsResolvedByTheContext()
        {
            // Arrange
            var request = typeof(Task <int>);
            var fixture = new Fixture();
            var context = new SpecimenContext(fixture);
            var sut     = new TaskGenerator();

            var frozenInt = fixture.Freeze <int>();
            // Act
            var task = (Task <int>)sut.Create(request, context);

            // Assert
            Assert.Equal(frozenInt, task.Result);
        }
        public void ResultOfGenericTasksIsResolvedByTheContext()
        {
            // Fixture setup
            var request = typeof(Task <int>);
            var fixture = new Fixture();
            var context = new SpecimenContext(fixture);
            var sut     = new TaskGenerator();

            var frozenInt = fixture.Freeze <int>();
            // Exercise system
            var task = (Task <int>)sut.Create(request, context);

            // Verify outcome
            Assert.Equal(frozenInt, task.Result);
            // Teardown
        }