public void SetUp()
        {
            _houseKeeper = new Housekeeper {
                Email = "a", FullName = "b", Oid = 1, StatementEmailBody = "c"
            };

            //First dependence for HouseKeeperService class
            var unitOfWork = new Mock <IUnitOfWork>();

            unitOfWork.Setup(uow => uow.Query <Housekeeper>()).Returns(new List <Housekeeper>
            {
                _houseKeeper
            }.AsQueryable());

            //Second dependence for HouseKeeperService class
            _statementGenerator = new Mock <IStatementGenerator>();

            //Third dependence for HouseKeeperService class
            _emailSender = new Mock <IEmailSender>();

            //Fourth dependence for HouseKeeperService class
            _messageBox = new Mock <IXtraMessageBox>();

            _service = new HousekeeperService(unitOfWork.Object,
                                              _statementGenerator.Object, _emailSender.Object, _messageBox.Object);
        }
        public void Setup()
        {
            _housekeeper = new Housekeeper {
                Email = "a", FullName = "b", Oid = 1, StatementEmailBody = "c"
            };

            var storage = new Mock <IHouseKeeperRepository>();

            storage.Setup(s => s.GetHousekeepers()).Returns(new List <Housekeeper>
            {
                _housekeeper
            }.AsQueryable());

            _statementFileName = "filename";
            _generator         = new Mock <IStatementReportGenerator>();
            _generator
            .Setup(g => g.SaveStatement(_housekeeper.Oid, _housekeeper.FullName, _statementDate))
            .Returns(() => _statementFileName);

            _emailHelper = new Mock <IEmailHelper>();
            _messageBox  = new Mock <IXtraMessageBox>();

            _service = new HousekeeperService(
                storage.Object,
                _generator.Object,
                _emailHelper.Object,
                _messageBox.Object);
        }
        public void SetUp()
        {
            _housekeeper = new Housekeeper {
                Email = "a", FullName = "b", Oid = 1, StatementEmailBody = "c"
            };

            var repository = new Mock <IHousekeeperRepository>();

            repository.Setup(r => r.GetHousekeepers()).Returns(new List <Housekeeper>
            {
                _housekeeper
            }.AsQueryable());

            _statementFileName  = "filename";
            _statementGenerator = new Mock <IStatementGenerator>();
            _statementGenerator
            .Setup(sg => sg.SaveStatement(_housekeeper.Oid, _housekeeper.FullName, _statementDate))
            .Returns(() => _statementFileName);

            _emailSender = new Mock <IEmailSender>();
            _messageBox  = new Mock <IXtraMessageBox>();

            _service = new HousekeeperService(
                repository.Object,
                _statementGenerator.Object,
                _emailSender.Object,
                _messageBox.Object);
        }
        public void SetUp()
        {
            // Arrange
            _unitOfWork         = Mock.Of <IUnitOfWork>();
            _statementGenerator = Mock.Of <IStatementGenerator>();
            _emailSender        = Mock.Of <IEmailSender>();
            _messageBox         = Mock.Of <IXtraMessageBox>();

            _service = new HousekeeperServiceWithDependencyInjection(_unitOfWork, _statementGenerator, _emailSender, _messageBox);

            _housekeeper = new Housekeeper
            {
                Email              = "a",
                FullName           = "b",
                Oid                = 1,
                StatementEmailBody = "c"
            };

            Mock.Get(_unitOfWork)
            .Setup(uow => uow.Query <Housekeeper>())
            .Returns(new List <Housekeeper> {
                _housekeeper
            }.AsQueryable());

            _statementFilename = "filename";
            Mock.Get(_statementGenerator)
            .Setup(sg => sg.SaveStatement(_housekeeper.Oid, _housekeeper.FullName, _statementDate))
            .Returns(() => _statementFilename);      // Func/delegate/lambda expression for "lazy evaluation" so we can change it in the Unit Tests
        }
Exemple #5
0
        public void Setup()
        {
            _unitOfWork  = new Mock <IUnitOfWork>();
            _houseKeeper = new Housekeeper {
                Oid = 1, Email = "a", FullName = "b", StatementEmailBody = "c"
            };

            _unitOfWork.Setup(uow => uow.Query <Housekeeper>()).Returns(new List <Housekeeper>
            {
                _houseKeeper
            }.AsQueryable());

            _statementFileName  = "filename";
            _statementGenerator = new Mock <IStatementGenerator>();
            _statementGenerator
            .Setup(sg => sg.SaveStatement(_houseKeeper.Oid, _houseKeeper.FullName, _statementDate))
            .Returns(() => _statementFileName);
            // NOTE: Lamda expression allows lazy loading. it means latest value of _statementFileName
            // is checked during test case
            // If we do not use lamda expression, then it will by default return 'fileName' value inititialized in previous step

            _emailSender = new Mock <IEmailSender>();
            _messageBox  = new Mock <IXtraMessageBox>();

            _service = new HousekeeperHelper(_unitOfWork.Object, _statementGenerator.Object, _emailSender.Object, _messageBox.Object);
        }
Exemple #6
0
        public void SetUp()
        {
            _houseKeeper = new Housekeeper
            {
                Email              = "a",
                FullName           = "b",
                Oid                = 1,
                StatementEmailBody = "c"
            };

            _unitOfWorkMock = new Mock <IUnitOfWorkRepository>();
            _unitOfWorkMock.Setup(ouw => ouw.Query <Housekeeper>()).Returns(new List <Housekeeper>
            {
                _houseKeeper
            }.AsQueryable());

            _statementFileName      = "fileName";
            _statementGeneratorMock = new Mock <IStatementGenerator>();
            _statementGeneratorMock
            .Setup(sg => sg.SaveStatement(_houseKeeper.Oid, _houseKeeper.FullName, _statementDate))
            .Returns(() => _statementFileName);

            _emailServiceMock   = new Mock <IEmailService>();
            _xtraMessageBoxMock = new Mock <IXtraMessageBox>();

            _service = new HousekeeperService(
                _unitOfWorkMock.Object,
                _statementGeneratorMock.Object,
                _emailServiceMock.Object,
                _xtraMessageBoxMock.Object);
        }
Exemple #7
0
        public void SetUp()
        {
            var unitOfWork = new Mock <IUnitOfWork>();

            _houseKeeper = new Housekeeper
            {
                Email              = "a",
                FullName           = "b",
                Oid                = 1,
                StatementEmailBody = "c"
            };
            unitOfWork.Setup(uow => uow.Query <Housekeeper>()).Returns(new List <Housekeeper>
            {
                _houseKeeper
            }.AsQueryable());

            _statementGenerator = new Mock <IStatementGenerator>();
            _emailSender        = new Mock <IEmailSender>();
            _messageBox         = new Mock <IXtraMessageBox>();

            _service = new RefacHouseKeeperHelper(unitOfWork.Object
                                                  , _statementGenerator.Object,
                                                  _emailSender.Object,
                                                  _messageBox.Object);
        }
Exemple #8
0
        public void SetUp()
        {
            _xtraMessageBox  = new Mock <IXtraMessageBox>();
            _emailFileSender = new Mock <IEmailFileSender>();

            _housekeeperStore = new Mock <IHousekeeperStore>();
            _housekeeper      = new Housekeeper
            {
                Email              = "*****@*****.**",
                Oid                = 1,
                FullName           = "Hosekeeper1",
                StatementEmailBody = "Email Body"
            };

            _housekeeperStore.Setup(fr => fr.GetHousekeepers()).Returns(
                new List <Housekeeper>
            {
                _housekeeper
            }.AsQueryable()
                );

            _statementSaver = new Mock <IHousekeeperStatementSaver>();
            _fileName       = "Statement.txt";
            _statementSaver.Setup(sS => sS.SaveStatement(
                                      _housekeeper.Oid,
                                      _housekeeper.FullName,
                                      _statementDate
                                      )).Returns(() => _fileName);
        }
Exemple #9
0
        public void SetUp()
        {
            _housekeeper = new Housekeeper
            {
                Email              = "a",
                FullName           = "b",
                Oid                = 1,
                StatementEmailBody = "c"
            };

            var unitOfWork = new Mock <IUnitOfWork>();

            unitOfWork.Setup(uow => uow.Query <Housekeeper>()).Returns(
                new List <Housekeeper>
            {
                _housekeeper
            }.AsQueryable);

            _statement = new Mock <IStatementGenerator>();
            _statement
            .Setup(sg => sg.SaveStatement(_housekeeper.Oid, _housekeeper.FullName, _statementDate))
            .Returns(() => _filename);     //We want to return a Null Function, not Null String for this Mock
            //Also with this Lazy Evaluation, this evaluation will be evaluated later
            _email       = new Mock <IEmailSender>();
            _xtraMessage = new Mock <IXtraMessageBox>();

            _service = new HousekeeperService(
                unitOfWork.Object,
                _statement.Object,
                _email.Object, _xtraMessage.Object);
        }
        public void Setup()
        {
            _housekeeper = new Housekeeper {
                Email = "a", FullName = "b", Oid = 1, StatementEmailBody = "c"
            };

            _unitOfWork = new Mock <IUnitOfWork>();
            _unitOfWork.Setup(s => s.Query <Housekeeper>()).Returns(new List <Housekeeper>
            {
                _housekeeper
            }.AsQueryable());

            _statementFileName = "filename";

            _statementGenerator = new Mock <IStatementGenerator>();
            _statementGenerator.Setup(v => v.SaveStatement(_housekeeper.Oid, _housekeeper.FullName, _statementDate))
            .Returns(() => _statementFileName);

            _emailSender = new Mock <IEmailSender>();
            _emailSender.Setup(v => v.EmailFile(It.IsAny <string>(),
                                                It.IsAny <string>(),
                                                It.IsAny <string>(),
                                                It.IsAny <string>()))
            .Throws <Exception>();

            _messageBox = new Mock <IXtraMessageBox>();

            service = new HousekeeperService(_unitOfWork.Object,
                                             _statementGenerator.Object,
                                             _emailSender.Object,
                                             _messageBox.Object);
        }
Exemple #11
0
        public void SetUp()
        {
            _houseKeeper = new Housekeeper
            {
                Email              = "a",
                FullName           = "b",
                Oid                = 1,
                StatementEmailBody = "c"
            };

            var unitOfWork = new Mock <IUnitOfWork>();

            unitOfWork.Setup(uow => uow.Query <Housekeeper>()).Returns(new List <Housekeeper>
            {
                _houseKeeper
            }.AsQueryable());

            _fileName           = "filename";
            _statementGenerator = new Mock <IStatementGenerator>();
            _statementGenerator
            .Setup(sg => sg.SaveStatement(_houseKeeper.Oid, _houseKeeper.FullName, _statementDate))
            .Returns(() => _fileName);

            _emailSender = new Mock <IEmailSender>();
            _messageBox  = new Mock <IXtraMessageBox>();

            _service = new HouseKeeperService(
                unitOfWork.Object,
                _statementGenerator.Object,
                _emailSender.Object,
                _messageBox.Object);
        }
Exemple #12
0
        public void Setup()
        {
            _date = new DateTime(2000, 1, 1);
            _statementFileName = "hi_there";
            _housekeeper       = new Housekeeper
            {
                Email = "a@a", FullName = "faa", Oid = 123, StatementEmailBody = "body"
            };

            _statementGenerator = new Mock <IStatementGenerator>();
            _statementGenerator.Setup(s => s.SaveStatement(_housekeeper.Oid, _housekeeper.FullName, _date))
            .Returns(() => _statementFileName);     // lazy evaluation

            var list = new List <Housekeeper> {
                _housekeeper
            };
            var unitOfWork = new Mock <IUnitOfWork>();

            unitOfWork.Setup(u => u.Query <Housekeeper>()).Returns(list.AsQueryable);

            _emailSender = new Mock <IEmailSender>();
            _messageBox  = new Mock <IXtraMessageBox>();
            _service     = new HousekeeperService(unitOfWork.Object,
                                                  _statementGenerator.Object,
                                                  _emailSender.Object,
                                                  _messageBox.Object);
        }
Exemple #13
0
        public void SetUp()
        {
            _houseKeeper = new Housekeeper {
                Email = "a", FullName = "b", Oid = 1, StatementEmailBody = "c"
            };
            var unitOfWork = new Mock <IUnitOfWork>();

            unitOfWork.Setup(uow => uow.Query <Housekeeper>()).Returns(new List <Housekeeper>
            {
                _houseKeeper
            }.AsQueryable());

            _statementFilename  = "filename"; // value for happy path.
            _statementGenerator = new Mock <IStatementGenerator>();
            _statementGenerator
            .Setup(sg => sg.SaveStatement(_houseKeeper.Oid, _houseKeeper.FullName, _statementDate))
            .Returns(() => _statementFilename);     // lambda expression for lazy evaluation. i.e. when test method
                                                    // changes the value of _statementFilename it uses the new value
                                                    // when this code is run, not the value assigned before.

            _emailSender = new Mock <IEmailSender>();
            _messageBox  = new Mock <IXtraMessageBox>();

            _service = new HousekeeperService(
                unitOfWork.Object,
                _statementGenerator.Object,
                _emailSender.Object,
                _messageBox.Object);
        }
        public void Setup()
        {
            _housekeeper = new Housekeeper {
                Email = "a", FullName = "b", Oid = 1, StatementEmailBody = "c"
            };
            _unitOfWork         = new Mock <IUnitOfWork>();
            _statementGenerator = new Mock <IStatementGenerator>();
            _emailSender        = new Mock <IEmailSender>();
            _messageBox         = new Mock <IXtraMessageBox>();
            _statementDate      = new DateTime(2018, 1, 2);
            _statementFilename  = "fileName";

            HousekeeperService.UnitOfWork         = _unitOfWork.Object;
            HousekeeperService.StatementGenerator = _statementGenerator.Object;
            HousekeeperService.EmailSender        = _emailSender.Object;
            HousekeeperService.XtraMessageBox     = _messageBox.Object;

            _unitOfWork.Setup(uow => uow.Query <Housekeeper>()).Returns(new List <Housekeeper> {
                _housekeeper
            }.AsQueryable());

            _statementGenerator
            .Setup(sg => sg.SaveStatement(_housekeeper.Oid, _housekeeper.FullName, _statementDate))
            // Use lamda to allow lazy evaluation, as we are overriding string value _statementFilename in some tests
            .Returns(() => _statementFilename);
        }
Exemple #15
0
        /// <summary>
        /// Serializa a binario todos los Companions de la lista Factory.ListaCompanions que ya hayan sido fabricados.
        /// Muestra un mensaje notificando cuantos Companions fueron serializados.
        /// </summary>
        private void btnBinarySer_Click(object sender, EventArgs e)
        {
            List <Companion> listaComp = Factory.ListaCompanions;
            int cantidadSerializados   = 0;

            foreach (Companion item in listaComp)
            {
                if (item.SelloFabricacion)
                {
                    if (item is Cook)
                    {
                        Cook aux = (Cook)item;
                        Serializer <Cook> .SerializeToBinary(aux, "Archivos\\listado_companions.bin");
                    }
                    else if (item is Housekeeper)
                    {
                        Housekeeper aux = (Housekeeper)item;
                        Serializer <Housekeeper> .SerializeToBinary(aux, "Archivos\\listado_companions.bin");
                    }
                    else
                    {
                        Manager aux = (Manager)item;
                        Serializer <Manager> .SerializeToBinary(aux, "Archivos\\listado_companions.bin");
                    }
                    cantidadSerializados++;
                }
            }
            MessageBox.Show($"{cantidadSerializados} Companion/s agregado/s al archvio binario.", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        public void SetUp()
        {
            _houseKeeper = new Housekeeper {
                Oid                = 11,
                FullName           = "Test name",
                Email              = "*****@*****.**",
                StatementEmailBody = "Hello"
            };

            _unitOfWork = new Mock <IUnitOfWork>();
            _unitOfWork.Setup(uow => uow.Query <Housekeeper>()).Returns(new List <Housekeeper> {
                _houseKeeper
            }.AsQueryable);

            _statementFileName = "fileName";

            _statementGenerator = new Mock <IStatementGenerator>();
            _statementGenerator
            .Setup(sg => sg.SaveStatement(_houseKeeper.Oid, _houseKeeper.FullName, _statementDate))
            .Returns(() => _statementFileName);

            _emailSender = new Mock <IEmailSender>();
            _messageBox  = new Mock <IXtraMessageBox>();

            _service = new HousekeeperService(_unitOfWork.Object, _statementGenerator.Object, _emailSender.Object, _messageBox.Object);
        }
        public void SetUp()
        {
            _housekeeper = new Housekeeper {
                Email = "a", FullName = "b", StatementEmailBody = "c", Oid = 1
            };

            _uow = new Mock <IUnitOfWork>();
            _uow.Setup(h => h.Query <Housekeeper>()).Returns(new List <Housekeeper>
            {
                _housekeeper
            }.AsQueryable);

            _statement = new Mock <IStatementGenerator>();
            _fileName  = "fileName";
            _statement
            .Setup(s => s.SaveStatement(_housekeeper.Oid, _housekeeper.FullName, _statementDateTime))
            .Returns(() => _fileName);

            _emailSender = new Mock <IEmailSender>();
            _messageBox  = new Mock <IXtraMessageBox>();

            _service = new HousekeeperService(
                _uow.Object,
                _statement.Object,
                _emailSender.Object,
                _messageBox.Object);
        }
 public void Setup()
 {
     housekeeper = new Housekeeper {
         Email = "*****@*****.**", FullName = "a", Oid = 1, StatementEmailBody = "body"
     };
     unitOfWork = new Mock <IUnitOfWork>();
     unitOfWork.Setup(u => u.Query <Housekeeper>()).Returns(new List <Housekeeper> {
         housekeeper
     }.AsQueryable());
 }
        public void Test_AgregarCompanion()
        {
            bool response;

            Housekeeper hk1 = new Housekeeper(
                new List <ETarea>()
            {
                ETarea.Barrer, ETarea.Limpiar, ETarea.Ordenar
            });

            response = Factory.AgregarCompanion(hk1);

            Assert.IsTrue(response);
        }
Exemple #20
0
 public void SetUp()
 {
     _housekeeper = new Housekeeper {
         Email = "a", FullName = "b", Oid = 1, StatementEmailBody = "c"
     };
     _repository = new Mock <IHouseKeeperRepository>();
     _repository.Setup(r => r.GetHouseKeepers()).Returns(new List <Housekeeper>
     {
         _housekeeper
     }
                                                         .AsQueryable());
     _statementHelper   = new Mock <IStatementHelper>();
     _emailHelper       = new Mock <IEmailHelper>();
     _xtraMessageHelper = new Mock <IXtraMessageBox>();
     _service           = new HousekeeperService(_repository.Object, _emailHelper.Object, _statementHelper.Object, _xtraMessageHelper.Object);
 }
Exemple #21
0
        public void SetUp()
        {
            _testHouseKeeper = new Housekeeper {
                Email = "a", FullName = "b", Oid = 1, StatementEmailBody = "c"
            };
            _mockDB = new Mock <IUnitOfWork>();
            _mockDB.Setup(x => x.Query <Housekeeper>()).Returns(new List <Housekeeper>
            {
                _testHouseKeeper
            }.AsQueryable());

            _filename      = "filename";
            _mockStatement = new Mock <IStatementGenerator>();
            _mockStatement.Setup(s => s.SaveStatement(_testHouseKeeper.Oid, _testHouseKeeper.FullName, _serviceDate))
            .Returns(() => _filename);
            _mockMB    = new Mock <IXtraMessageBox>();
            _mockEmail = new Mock <IEmailSender>();
            _service   = new HousekeeperHelper(_mockDB.Object, _mockStatement.Object, _mockEmail.Object, _mockMB.Object);
        }
Exemple #22
0
        public void SetUp()
        {
            _keeper = new Housekeeper {
                Email = "a", FullName = "b", Oid = 1, StatementEmailBody = "something"
            };

            _unitOfWork = new Mock <IUnitOfWork>();
            _unitOfWork.Setup(un => un.Query <Housekeeper>()).Returns(new List <Housekeeper> {
                _keeper
            }.AsQueryable());

            _statementFileName  = "filename";
            _statementGenerator = new Mock <IStatementGenerator>();
            _statementGenerator.Setup(sg => sg.SaveStatement(_keeper.Oid, _keeper.FullName, date))
            .Returns(() => _statementFileName);

            _emailSender    = new Mock <IEmailSender>();
            _xtraMessageBox = new Mock <IXtraMessageBox>();
            _services       = new HouseKeeperService(_unitOfWork.Object, _statementGenerator.Object, _emailSender.Object, _xtraMessageBox.Object);
        }
Exemple #23
0
        public void Setup()
        {
            _houseKeeperRepository = new Mock <IHouseKeeperRepository>();
            _houseKeeper           = new Housekeeper()
            {
                Email = "a", Oid = 1, FullName = "b", StatementEmailBody = "c"
            };

            _houseKeeperRepository.Setup(hkr => hkr.GetHousekeepers()).Returns(new List <Housekeeper> {
                _houseKeeper
            }.AsQueryable());
            _statementGenerator = new Mock <IStatementGenerator>();
            _emailSender        = new Mock <IEmailSender>();
            _messageBox         = new Mock <IXtraMessageBox>();
            _sendingTime        = new DateTime(2020, 9, 20);

            _housekeeperHelper = new HousekeeperHelper(_houseKeeperRepository.Object,
                                                       _statementGenerator.Object,
                                                       _emailSender.Object,
                                                       _messageBox.Object);
        }
Exemple #24
0
        public void SetUp()
        {
            //Arrange
            _houseKeeper = new Housekeeper()
            {
                Oid                = 1,
                Email              = "a",
                FullName           = "b",
                StatementEmailBody = "c"
            };
            _unitOfWorkMock = new Mock <IUnitOfWork>();
            _unitOfWorkMock
            .Setup(u => u.Query <Housekeeper>())
            .Returns(new List <Housekeeper>()
            {
                _houseKeeper
            }.AsQueryable);


            _statementFilename      = "filename";
            _statementGeneratorMock = new Mock <IStatementGenerator>();
            _statementGeneratorMock
            .Setup(sg => sg.SaveStatement(
                       _houseKeeper.Oid,
                       _houseKeeper.FullName,
                       _statementDate))
            .Returns(() => _statementFilename);


            _emailSenderMock    = new Mock <IEmailSender>();
            _xtraMessageBoxMock = new Mock <IXtraMessageBox>();

            //service
            _houseKeeperService = new HousekeeperService(
                _unitOfWorkMock.Object,
                _statementGeneratorMock.Object,
                _emailSenderMock.Object,
                _xtraMessageBoxMock.Object);
        }
Exemple #25
0
 public void MergeFrom(HousekeepingAssignment other)
 {
     if (other == null)
     {
         return;
     }
     if (other.createdAt_ != null)
     {
         if (createdAt_ == null)
         {
             createdAt_ = new global::Google.Protobuf.WellKnownTypes.Timestamp();
         }
         CreatedAt.MergeFrom(other.CreatedAt);
     }
     if (other.effectiveDate_ != null)
     {
         if (effectiveDate_ == null)
         {
             effectiveDate_ = new global::HOLMS.Types.Primitive.PbLocalDate();
         }
         EffectiveDate.MergeFrom(other.EffectiveDate);
     }
     if (other.housekeeper_ != null)
     {
         if (housekeeper_ == null)
         {
             housekeeper_ = new global::HOLMS.Types.IAM.StaffMemberIndicator();
         }
         Housekeeper.MergeFrom(other.Housekeeper);
     }
     if (other.room_ != null)
     {
         if (room_ == null)
         {
             room_ = new global::HOLMS.Types.Operations.Rooms.RoomIndicator();
         }
         Room.MergeFrom(other.Room);
     }
 }
Exemple #26
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (createdAt_ != null)
            {
                hash ^= CreatedAt.GetHashCode();
            }
            if (effectiveDate_ != null)
            {
                hash ^= EffectiveDate.GetHashCode();
            }
            if (housekeeper_ != null)
            {
                hash ^= Housekeeper.GetHashCode();
            }
            if (room_ != null)
            {
                hash ^= Room.GetHashCode();
            }
            return(hash);
        }
        public void Setup()
        {
            _housekeeper = new Housekeeper {
                Email = "a", FullName = "b", Oid = 1, StatementEmailBody = "c"
            };

            _unitOfWork = new Mock <IUnitOfWork>();
            _unitOfWork.Setup(uow => uow.Query <Housekeeper>()).Returns(new List <Housekeeper>
            {
                _housekeeper
            }.AsQueryable());

            _statementFileName = "filename";

            _houseKeeperFunctions = new Mock <IHouseKeeperFunctions>();
            _xtraMessageBox       = new Mock <IXtraMessageBox>();
            _service = new HousekeeperHelper(_unitOfWork.Object, _houseKeeperFunctions.Object, _xtraMessageBox.Object);

            _houseKeeperFunctions
            .Setup(hk =>
                   hk.SaveStatement(_housekeeper.Oid, _housekeeper.FullName, (_statementDate)))
            .Returns(() => _statementFileName);
        }
Exemple #28
0
        /// <summary>
        /// Click del botón btnAgregar. Dependiendo del tipo de Companion que se desee crear, toma datos y los agrega
        /// a la lista en forma de nuevo objeto Companion.
        /// </summary>
        private void btnAgregar_Click(object sender, EventArgs e)
        {
            string            tipoCompanion = this.cmbBoxTipo.Text;
            List <ETarea>     tareas        = new List <ETarea>();
            List <EUtensilio> utensilios    = new List <EUtensilio>();

            try
            {
                switch (this.cmbBoxTipo.Text)
                {
                case "Cook":
                    if (this.chBoxCocinar.Checked == true)
                    {
                        tareas.Add(ETarea.Cocinar);
                    }
                    if (this.chBoxComprarComida.Checked == true)
                    {
                        tareas.Add(ETarea.ComprarComida);
                    }
                    if (this.chBoxCubiertos.Checked == true)
                    {
                        utensilios.Add(EUtensilio.Cubiertos);
                    }
                    if (this.chBoxOllas.Checked == true)
                    {
                        utensilios.Add(EUtensilio.Ollas);
                    }
                    if (this.chBoxSartenes.Checked == true)
                    {
                        utensilios.Add(EUtensilio.Sartenes);
                    }
                    Cook cookToCreate = new Cook(tareas, utensilios);
                    NameGenerator <Cook> .CompanionName(cookToCreate);

                    Factory.AgregarCompanion(cookToCreate);
                    MessageBox.Show("Nuevo Cook creado con éxito!");
                    this.Close();
                    break;

                case "Housekeeper":
                    if (this.chBoxLimpiar.Checked == true)
                    {
                        tareas.Add(ETarea.Limpiar);
                    }
                    if (this.chBoxOrdenar.Checked == true)
                    {
                        tareas.Add(ETarea.Ordenar);
                    }
                    if (this.chBoxBarrer.Checked == true)
                    {
                        tareas.Add(ETarea.Barrer);
                    }
                    Housekeeper housekeeperToCreate = new Housekeeper(tareas);
                    NameGenerator <Housekeeper> .CompanionName(housekeeperToCreate);

                    Factory.AgregarCompanion(housekeeperToCreate);
                    MessageBox.Show("Nuevo Housekeeper creado con éxito!");
                    this.Close();
                    break;

                case "Manager":
                    if (this.chBoxComprarComida.Checked == true)
                    {
                        tareas.Add(ETarea.ComprarComida);
                    }
                    if (this.chBoxOrganizarGastos.Checked == true)
                    {
                        tareas.Add(ETarea.OrganizarGastos);
                    }
                    if (this.cmbBoxNivelAcceso.Text == "Bajo" || this.cmbBoxNivelAcceso.Text == "Medio" || this.cmbBoxNivelAcceso.Text == "Alto")
                    {
                        Manager managerToCreate = new Manager(tareas, this.cmbBoxNivelAcceso.Text);
                        NameGenerator <Manager> .CompanionName(managerToCreate);

                        Factory.AgregarCompanion(managerToCreate);
                    }
                    else
                    {
                        throw new InvalidAccessLevelException("No ha seleccionado un nivel de acceso válido. Si eligió \"Manager\", se le asignará Bajo como nivel de acceso.");
                    }

                    MessageBox.Show("Nuevo Manager creado con éxito!");
                    this.Close();
                    break;

                default:
                    throw new InvalidCompanionNameException("No ha seleccionado un tipo de Companion válido. Se le asignará un Housekeeper.");
                }
            }
            catch (FabricaApagadaException ex)
            {
                MessageBox.Show(ex.Message, "Fábrica apagada!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                this.Close();
            }
            catch (InvalidAccessLevelException ex)
            {
                MessageBox.Show(ex.Message, "Nivel de acceso inválido!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.cmbBoxNivelAcceso.Text = "Bajo";
            }
            catch (InvalidCompanionNameException ex)
            {
                MessageBox.Show(ex.Message, "Tipo inválido!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.cmbBoxTipo.Text = "Housekeeper";
            }
        }
Exemple #29
0
        public static bool RegisterInPartialTrust(HttpApplication application, IHttpModule module)
        {
            if (application == null)
            {
                throw new ArgumentNullException("application");
            }

            if (module == null)
            {
                throw new ArgumentNullException("module");
            }

            if (IsHighlyTrusted())
            {
                return(false);
            }

            lock (_lock)
            {
                //
                // On-demand allocate a map of modules per application.
                //

                if (_moduleListByApp == null)
                {
                    _moduleListByApp = new Dictionary <HttpApplication, IList <IHttpModule> >();
                }

                //
                // Get the list of modules for the application. If this is
                // the first registration for the supplied application object
                // then setup a new and empty list.
                //

                var moduleList = _moduleListByApp.Find(application);

                if (moduleList == null)
                {
                    moduleList = new List <IHttpModule>();
                    _moduleListByApp.Add(application, moduleList);
                }
                else if (moduleList.Contains(module))
                {
                    throw new ApplicationException("Duplicate module registration.");
                }

                //
                // Add the module to list of registered modules for the
                // given application object.
                //

                moduleList.Add(module);
            }

            //
            // Setup a closure to automatically unregister the module
            // when the application fires its Disposed event.
            //

            Housekeeper housekeeper = new Housekeeper(module);

            application.Disposed += new EventHandler(housekeeper.OnApplicationDisposed);

            return(true);
        }
        public static bool RegisterInPartialTrust(HttpApplication application, IHttpModule module)
        {
            if (application == null)
                throw new ArgumentNullException("application");

            if (module == null)
                throw new ArgumentNullException("module");

            if (IsHighlyTrusted())
                return false;
            
            lock (_lock)
            {
                //
                // On-demand allocate a map of modules per application.
                //

                if (_moduleListByApp == null)
                    _moduleListByApp = new Dictionary<HttpApplication, IList<IHttpModule>>();

                //
                // Get the list of modules for the application. If this is
                // the first registration for the supplied application object
                // then setup a new and empty list.
                //

                var moduleList = _moduleListByApp.Find(application);
                
                if (moduleList == null)
                {
                    moduleList = new List<IHttpModule>();
                    _moduleListByApp.Add(application, moduleList);
                }
                else if (moduleList.Contains(module))
                    throw new ApplicationException("Duplicate module registration.");

                //
                // Add the module to list of registered modules for the 
                // given application object.
                //

                moduleList.Add(module);
            }

            //
            // Setup a closure to automatically unregister the module
            // when the application fires its Disposed event.
            //

            var housekeeper = new Housekeeper(module);
            application.Disposed += housekeeper.OnApplicationDisposed;

            return true;
        }
Exemple #31
0
        public void InstatnciateSimple(HotelManagementContext context)
        {
            var guest1 = new Guest()
            {
                FirstName = "Sondre", Lastname = " Fingann", PhoneNumber = "98848184", Username = "******", PasswordHash = "Sondre123"
            };
            var guest2 = new Guest()
            {
                FirstName = "Tore", Lastname = " Stensrup", PhoneNumber = "43992834", Username = "******", PasswordHash = "tore124"
            };
            var guest3 = new Guest()
            {
                FirstName = "Jonas", Lastname = " Øvreset", PhoneNumber = "83374561", Username = "******", PasswordHash = "jonas123"
            };
            var guest4 = new Guest()
            {
                FirstName = "Nils", Lastname = "Kondens", PhoneNumber = "45734821", Username = "******", PasswordHash = "nils123"
            };

            var receptionist1 = new Receptionist()
            {
                FirstName = "Fred", Lastname = "Singer", PhoneNumber = "48837745", Username = "******", PasswordHash = "Receptionist1", JobDescription = "Receptionist"
            };
            var receptionist2 = new Receptionist()
            {
                FirstName = "Roy", Lastname = "Averson", PhoneNumber = "48837745", Username = "******", PasswordHash = "Receptionist2", JobDescription = "Receptionist"
            };

            var housekeeper1 = new Housekeeper()
            {
                FirstName = "Stian", Lastname = "Stensrup", PhoneNumber = "43992834", Username = "******", PasswordHash = "Housekeeper1", JobDescription = "Housekeeper"
            };
            var foodServent = new FoodServent()
            {
                FirstName = "Gordon", Lastname = "Øvreset", PhoneNumber = "83374561", Username = "******", PasswordHash = "Foodservent1", JobDescription = "FoodServer"
            };
            var janitor = new Janitor()
            {
                FirstName = "Terje", Lastname = "Lillebø", PhoneNumber = "83374561", Username = "******", PasswordHash = "Janitor1", JobDescription = "Janitor"
            };

            context.Guests.Add(guest1);
            context.Guests.Add(guest2);
            context.Guests.Add(guest3);
            context.Guests.Add(guest4);
            context.SaveChanges();

            context.Employees.Add(receptionist1);
            context.Employees.Add(receptionist2);
            context.Employees.Add(housekeeper1);
            context.Employees.Add(foodServent);
            context.Employees.Add(janitor);
            context.SaveChanges();

            for (int i = 0; i < 25; i++)
            {
                Rooms.Add(new SingleRoom()
                {
                    RoomNumber = "A" + i, Quality = "Vip"
                });
                Rooms.Add(new DoubleRoom()
                {
                    RoomNumber = "B" + i, Quality = "Standard"
                });
                Rooms.Add(new SingleRoom()
                {
                    RoomNumber = "A" + (i + 25), Quality = "Standard"
                });
                Rooms.Add(new DoubleRoom()
                {
                    RoomNumber = "B" + (i + 25), Quality = "Vip"
                });
            }
            //Rooms[7].State = new NotCleanedState();
            //Rooms[8].State = new NotCleanedState();
            //Rooms[9].State = new MaintenanceState();


            context.Rooms.AddRange(Rooms);
            context.SaveChanges();

            //var cleaningService = new HousekeepingService() { Ordered = DateTime.Now, RoomId = Rooms[7].Id };
            //var cleaningService2 = new HousekeepingService() { Ordered = DateTime.Now, RoomId = Rooms[8].Id };
            //var maintnanceService = new JanitorService(){Ordered = DateTime.Now,RoomId = Rooms[9].Id};
            //var foodService = new FoodService(){Ordered = DateTime.Now, RoomId = Rooms[9].Id};

            //context.RoomServices.AddRange(
            //    new List<RoomService>() {cleaningService, cleaningService2, maintnanceService});
        }
		private void MonitorClients()
		{
			Housekeeper objHousekeeper = null;

			// Note. Dedicated to removing disconnected and otherwise dormant Tcp Clients

			objHousekeeper = new Housekeeper();
			objHousekeeper.OnCallback-= new Housekeeper.ParentCallback(objHousekeeper.InvokeParentCallback);
			objHousekeeper.OnCallback+= new Housekeeper.ParentCallback(this.InvokeParentCallback);

			mobjMonitor=new PollingThread(objHousekeeper,POLLING_INTERVAL_SECS,"Thread_Housekeeper");
			mobjMonitor.Start();

		}