Ejemplo n.º 1
0
        public void Exsiting_GivenIdEqual7_ReturnWithIdEqual7()
        {
            var givenId = 7;

            var estimation = Estimation.Existing(givenId, "id", "specNumber", "Description", "unit", 1, 1, 1, new CompanyId(1));

            Assert.That(estimation.Id, Is.EqualTo(givenId), $"Id should be {givenId}, but is {estimation.Id}");
        }
        public void CanEdit_False_UserIsAdminButNotWorksInMainContractor()
        {
            var estimation       = Estimation.Existing(12, "", "", "", "", 1, 1, 1, new CompanyId(12));
            var userId           = new UserId(2);
            var buildingId       = new BuildingId(4);
            var mainContractorId = new CompanyId(14);

            var user = new User(userId, "", "", UserCompanyRole.Worker, "");

            user.From(new CompanyId(12));
            user.AddRole(buildingId, UserBuildingRole.Admin);
            _userRepository.Get(userId).Returns(user);

            var building = new Core.Domain.Models.Building(buildingId, "name", new Company(mainContractorId, "cName", "cNumber"));

            _buildingRepository.Get(buildingId).Returns(building);

            var canEdit = _estimationAccessRule.CanEdit(estimation, userId, buildingId);

            Assert.IsFalse(canEdit);
        }