Exemple #1
0
        public void ACRSumamrySetup()
        {
            _acrDetails         = FakeDatabase.AcrList();
            _acrStatus          = FakeDatabase.StatusList();
            _UsersAssignedToACR = FakeDatabase.UserList();
            _assignees          = FakeDatabase.GetAssignees();

            _acrSumRepository.Setup(a => a.GetACRSummary(It.IsAny <int>())).Returns((int i) => _acrDetails.Where(x => x.ACRID == i).Single().Summary.ToString());
            _acrStatusRepository.Setup(a => a.GetACRStatus(It.IsAny <int>())).Returns((int i) => _acrStatus.Where(x => x.StatusId == _acrDetails.FirstOrDefault().StatusId).Single().StatusName.ToString());
            _acrAssignedToRepository.Setup(a => a.ACRAssignedTo(It.IsAny <int>())).Returns(() => _assignees.Where(a => a.UserId == _UsersAssignedToACR.FirstOrDefault().UserID).Select(s => s.User.FirstName + " " + s.User.LastName).ToList <string>());
            this._ACRRepository           = _acrSumRepository.Object;
            this._ACRStatusRepository     = _acrStatusRepository.Object;
            this._ACRAssignedToRepository = _acrAssignedToRepository.Object;
        }
        public void ACRTestSetUp()
        {
            _status = FakeDatabase.StatusList();

                    _acr = FakeDatabase.AcrList();

                    _statusRepository  = new Mock<IStatusRepository>();
                    _acrRepository = new Mock<IACRRepository>();

                    _acrRepository.Setup( a => a.GetACRStatus(It.IsAny<int>())).Returns(() => _status.Where(x => x.StatusId==_acr.FirstOrDefault().StatusId).Single().StatusName.ToString());

                    _statusRepository.Setup(s => s.All).Returns(_status.Where(i => i.IsActive==true).AsQueryable<StatusMaster>());

                    this._ACRRepository = _acrRepository.Object;

                    this._StatusRepository = _statusRepository.Object;
        }
        public void Init()
        {
            _status = FakeDatabase.StatusList();

            _acr = FakeDatabase.AcrList();

            _assigneeMapping = FakeDatabase.GetAssignees();

            _statusRepository = new Mock<IStatusRepository>();
            _acrRepository = new Mock<IACRRepository>();

            _acrStatus = new ACRStatus();
            _acrRepository.Setup(a => a.GetNumberOfAssignees(It.IsAny<int>())).Returns((int i) => _assigneeMapping.Where(m => m.ACRId==i).Count());
            _acrRepository.Setup(a => a.GetACRStatus(It.IsAny<int>())).Returns(() => _status.Where(x => x.StatusId == _acr.FirstOrDefault().StatusId).Single().StatusName.ToString());
            this._ACRRepository = _acrRepository.Object;
            this._StatusRepository = _statusRepository.Object;
        }
Exemple #4
0
        public void Init()
        {
            _status = FakeDatabase.StatusList();

            _acr = FakeDatabase.AcrList();

            _assigneeMapping = FakeDatabase.GetAssignees();

            _statusRepository = new Mock <IStatusRepository>();
            _acrRepository    = new Mock <IACRRepository>();

            _acrStatus = new ACRStatus();
            _acrRepository.Setup(a => a.GetNumberOfAssignees(It.IsAny <int>())).Returns((int i) => _assigneeMapping.Where(m => m.ACRId == i).Count());
            _acrRepository.Setup(a => a.GetACRStatus(It.IsAny <int>())).Returns(() => _status.Where(x => x.StatusId == _acr.FirstOrDefault().StatusId).Single().StatusName.ToString());
            this._ACRRepository    = _acrRepository.Object;
            this._StatusRepository = _statusRepository.Object;
        }
            public void InitSetUp()
            {
                _testACR = FakeDatabase.ACRList();

                _mockACRRepository = new Mock <IACRRepository>();

                // Try Finding All ACRs
                _mockACRRepository.Setup(a => a.FindAll()).Returns(_testACR);


                // Try finding ACRs by ACR Name
                _mockACRRepository.Setup(a => a.FindByACRName(It.IsAny <string>())).Returns((string s) => _testACR.Where(x => x.ACR_Name == s).Single());


                // Try finding ACRs by AppId
                _mockACRRepository.Setup(a => a.FindByAppId(It.IsAny <int>())).Returns((int i) => _testACR.Where(x => x.ApplicationId == i).ToList());

                // Try finding ACRs by StatusId
                _mockACRRepository.Setup(a => a.FindByStatusId(It.IsAny <int>())).Returns((int i) => _testACR.Where(x => x.StatusId == i).ToList());

                // Try Saving the Changes
                _mockACRRepository.Setup(a => a.Save()).Verifiable("Save Not Successful");

                // Insert or Update
                _mockACRRepository.Setup(a => a.InsertOrUpdate(It.IsAny <ACR>())).Callback(
                    (ACR acrTarget) =>
                {
                    if (acrTarget.ACRID.Equals(default(int))) // for INSERT
                    {
                        acrTarget.ACRID = _testACR.Count() + 1;
                        _testACR.Add(acrTarget);
                    }

                    else // for UPDATE
                    {
                        var original           = _testACR.Where(o => o.ACRID == acrTarget.ACRID).Single();
                        original.ACR_Name      = acrTarget.ACR_Name;
                        original.ApplicationId = acrTarget.ApplicationId;
                        original.Summary       = acrTarget.Summary;
                        original.StatusId      = acrTarget.StatusId;
                    }
                });

                this._acrRepository = _mockACRRepository.Object;
            }
Exemple #6
0
        public void ACRTestSetUp()
        {
            _status = FakeDatabase.StatusList();

            _acr = FakeDatabase.AcrList();

            _statusRepository = new Mock <IStatusRepository>();
            _acrRepository    = new Mock <IACRRepository>();

            _acrRepository.Setup(a => a.GetACRStatus(It.IsAny <int>())).Returns(() => _status.Where(x => x.StatusId == _acr.FirstOrDefault().StatusId).Single().StatusName.ToString());


            _statusRepository.Setup(s => s.All).Returns(_status.Where(i => i.IsActive == true).AsQueryable <StatusMaster>());

            this._ACRRepository = _acrRepository.Object;

            this._StatusRepository = _statusRepository.Object;
        }
            public void InitSetUp()
            {
                _testACR = FakeDatabase.ACRList();

                _mockACRRepository = new Mock<IACRRepository>();

                // Try Finding All ACRs
                _mockACRRepository.Setup(a => a.FindAll()).Returns(_testACR);

                // Try finding ACRs by ACR Name
                _mockACRRepository.Setup(a => a.FindByACRName(It.IsAny<string>())).Returns((string s) => _testACR.Where(x => x.ACR_Name == s).Single());

                // Try finding ACRs by AppId
                _mockACRRepository.Setup(a => a.FindByAppId(It.IsAny<int>())).Returns((int i) => _testACR.Where(x => x.ApplicationId == i).ToList());

                // Try finding ACRs by StatusId
                _mockACRRepository.Setup(a => a.FindByStatusId(It.IsAny<int>())).Returns((int i) => _testACR.Where(x => x.StatusId == i).ToList());

                // Try Saving the Changes
                _mockACRRepository.Setup(a => a.Save()).Verifiable("Save Not Successful");

                // Insert or Update
                _mockACRRepository.Setup(a => a.InsertOrUpdate(It.IsAny<ACR>())).Callback(
                (ACR acrTarget) =>
                {
                    if (acrTarget.ACRID.Equals(default(int))) // for INSERT
                    {
                        acrTarget.ACRID = _testACR.Count() + 1;
                        _testACR.Add(acrTarget);
                    }

                    else // for UPDATE
                    {
                        var original = _testACR.Where(o => o.ACRID == acrTarget.ACRID).Single();
                        original.ACR_Name = acrTarget.ACR_Name;
                        original.ApplicationId = acrTarget.ApplicationId;
                        original.Summary = acrTarget.Summary;
                        original.StatusId = acrTarget.StatusId;
                    }

                });

                this._acrRepository = _mockACRRepository.Object;
            }
Exemple #8
0
 public ACRController(IACRRepository acrRepository)
 {
     _acrRepository = acrRepository;
 }