コード例 #1
0
        public async Task Get_Id_GetsOrganization(
            bool exists,
            Type resultType
            )
        {
            var id = 1;

            var returns        = exists ? new Organization() : null;
            var _organizations = new Mock <IOrganizationRepository>();

            _organizations.Setup(o => o.GetOrganizationByIdAsync(id))
            .ReturnsAsync(returns);

            var controller = new OrganizationsController(_organizations.Object);

            var result = await controller.Get(id);

            _organizations.Verify(o => o.GetOrganizationByIdAsync(id), Times.Once());
            Assert.IsType(resultType, result.Result);
        }
コード例 #2
0
        public void Get_Id_Include_GetsOrganization_WithInclude(
            bool exists,
            Type resultType
            )
        {
            var id      = 1;
            var include = new string[] { "foo" };

            var returns        = exists ? new Organization() : null;
            var _organizations = new Mock <IOrganizationRepository>();

            _organizations.Setup(o => o.GetOrganizationById(id, include))
            .Returns(returns);

            var controller = new OrganizationsController(_organizations.Object);

            var result = controller.Get(id, include);

            _organizations.Verify(o => o.GetOrganizationById(id, include), Times.Once());
            Assert.IsType(resultType, result.Result);
        }
コード例 #3
0
        public void GetAllTest()
        {
            var organizations = _controller.Get();

            Assert.Equal(2, organizations.Count());
        }