示例#1
0
    public void GetFORMsTest()
    {
        // ARRANGE
        var expected = new FormModel();

        _mapperMock.Setup(m =>
                          m.Map <FORM, FormModel>(It.IsAny <FORM>())
                          ).Returns(expected);

        _mockContext = new Mock <DvrrEntities>();
        _mockContext.Setup(m => m.FORMs)
        .ReturnsDbSet(MockHelpers.CreateTestForms());
        _mockContext.Setup(m => m.FORM_STATUS)
        .ReturnsDbSet(MockHelpers.CreateFormStatus());
        _mockContext.Setup(m => m.FORM_AUDIT)
        .ReturnsDbSet(MockHelpers.CreateTestAudits());

        // ACT
        var controller = new ExController(
            _mockContext.Object,
            _mapperMock.Object,
            _emailServiceMock.Object);

        controller.ShouldNotBeNull();

        var forms = controller.GetFORMs();

        // ASSERT
        _mockContext.Verify(v => v.FORMs);

        forms.ShouldNotBeNull();
        forms.Count().ShouldBe(2);
    }