/// <summary>
        ///     Initializes a new instance of the <see cref="StudentControllerTests" /> class.
        /// </summary>
        public StudentControllerTests()
        {
            var options = new DbContextOptionsBuilder <PhsomContext>().UseInMemoryDatabase("KLS").Options;

            context = new PhsomContext(options);

            if (!initialized)
            {
                Mapper.Initialize(config => { config.AddProfile <MappingProfile>(); });
                initialized = true;
            }
        }
        public async Task PostStudentThrowsInvalidOperationExecption()
        {
            var options = new DbContextOptionsBuilder <PhsomContext>().UseInMemoryDatabase("KLS").Options;

            context = new PhsomContext(options);
            var request    = new StudentCreation();
            var controller = new StudentController(context, new NullLogger <StudentController>());
            await controller.Post(new StudentCreation()).ConfigureAwait(false);

            request.StudentId = 1;
            var result = await controller.Post(request).ConfigureAwait(false);

            result.Should().BeOfType <ObjectResult>();
            ((ObjectResult)result).StatusCode.Should().Be((int)HttpStatusCode.InternalServerError);
        }
Пример #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ProfileController"/> class.
 /// </summary>
 /// <param name="context">
 /// The context.
 /// </param>
 public ProfileController(PhsomContext context)
 {
     this.context = context;
 }
 /// <summary>
 ///     Initializes a new instance of the <see cref="StudentController" /> class.
 /// </summary>
 /// <param name="phsomContext">
 ///     The PHSOM context.
 /// </param>
 /// <param name="logger">
 ///     The logger.
 /// </param>
 public StudentController(PhsomContext phsomContext, ILogger <StudentController> logger)
 {
     this.phsomContext = phsomContext;
     this.logger       = logger;
 }