public Chapter5() { /*Возврат объекта из метода*/ FactoryClass obj = new FactoryClass(); int a, b; //наделать объектов используя метод Factory for (a = 0, b = 10; a < 10; a++, b--) { FactoryClass anotherObj = obj.Factory(a, b); //создать новый объект anotherObj.Show(); } /*********************************/ /*возврат массива из метода*/ int numfactors; int[] factors; factors = obj.FindFactors(1000, out numfactors); Console.WriteLine("fact 1000: "); for (int i = 0; i < numfactors; i++) Console.Write(factors[i] + " "); Console.WriteLine(); }
public void GetAll_EmptyParameter_ExpectedLengthGraterThanZero() { IRepository <ApiEmployee> _repository = FactoryClass.MakeEmployeeRepository(); List <ApiEmployee> allEmployee = _repository.GetAll().ToList(); Assert.IsTrue(allEmployee.Count > 0); }
public void Get_EmptyIDParameter_ExpectedObjectnotNUll() { IRepository <ApiEmployee> _repository = FactoryClass.MakeEmployeeRepository(); List <ApiEmployee> allEmployee = _repository.GetAll().ToList(); int id = allEmployee.FirstOrDefault().id; ApiEmployee employee = _repository.Get(id); Assert.IsTrue(employee != null); }
public static void Main(string[] args) { var newWork = FactoryClass.Create <IDoWork>("DoWorkType1"); Console.WriteLine(newWork.Process()); newWork = FactoryClass.Create <IDoWork>("DoWorkType2"); Console.WriteLine(newWork.Process()); Console.Read(); }
public List <OfferBll> GetAllOffers(ParametersBll parametersBll) { List <OfferBll> offers = new List <OfferBll>(); foreach (Offer offer in _dataSource.GetAllOffers()) { offers.Add(FactoryClass.CreateChild(offer)); } return(offers.GetRange((parametersBll.Page - 1) * parametersBll.PageSize, parametersBll.PageSize)); }
public void TestSiCiDemo1() { //Arrange I1 i2 = FactoryClass.GetSiCi(0); //Act float res = i2.Interest(40, 50, 20); //Assert Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreEqual(100, res); }
public List <OfferBll> GetAllOffers() { List <OfferBll> offersBll = new List <OfferBll>(); foreach (var offer in _dataSource.GetAllOffers()) { offersBll.Add(FactoryClass.CreateChild(offer)); } return(offersBll); }
public static ISomething Instance(int param) { lock (privateObject) { if (privateObject == null) { privateObject = FactoryClass.CreationObject(param); } } return(privateObject); }
public static void Main(string[] args) { var newWork = FactoryClass.Create <IDoWork>("DoWorkType1"); Console.WriteLine(newWork.Process()); newWork = FactoryClass.Create <IDoWork>("DoWorkType2"); Console.WriteLine(newWork.Process()); // repeat with DoWorkType1 just to show it coming from dictionary newWork = FactoryClass.Create <IDoWork>("DoWorkType1"); Console.WriteLine(newWork.Process()); Console.Read(); }
public ActionResult Edit(CommandModel cModel) { var commandobj = FactoryClass.GetCommand(); commandobj.Id = cModel.Id; commandobj.Name = cModel.Name; commandobj.Usage = cModel.Usage; commandobj.Description = cModel.Description; _commandCollection.Update(commandobj); return(RedirectToAction("Commands")); }
public void TestSiCiDemo() { //Arrange I1 i1 = FactoryClass.GetSiCi(0); //Act float result = i1.Interest(10, 20, 30); double result1 = i1.CalculateCompoundInterest(1000, 0.07, 1); //Assert Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreEqual(60, result); Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreEqual(1070, result1); }
/// <summary> /// return Payment response /// </summary> /// <returns></returns> private PaymentResponse GetPaymentResponse(PaymentRequest objPaymentRequest) { var objPaymentResonse = new PaymentResponse(); try { if (objPaymentRequest == null) { objPaymentResonse.StatusCode = (int)HttpStatusCode.BadRequest; objPaymentResonse.StatusDesc = "Invalid request format"; objPaymentResonse.MessageId = ""; } else { var objFactoryClass = new FactoryClass(); var objPaymenType = objFactoryClass.GetPaymentType(objPaymentRequest); if (objPaymenType != null) { string response; if (objPaymenType.ProcessPayment(objPaymentRequest, out response)) { objPaymentResonse.StatusCode = (int)HttpStatusCode.OK; objPaymentResonse.StatusDesc = response; objPaymentResonse.MessageId = objPaymentRequest.PaymentId.ToString(); } else { objPaymentResonse.StatusCode = (int)HttpStatusCode.NotAcceptable; objPaymentResonse.StatusDesc = response; objPaymentResonse.MessageId = objPaymentRequest.PaymentId.ToString(); } } else { objPaymentResonse.StatusCode = (int)HttpStatusCode.NotAcceptable; objPaymentResonse.StatusDesc = "Invalid payment type"; objPaymentResonse.MessageId = ""; } } } catch (Exception ex) { objPaymentResonse.StatusCode = (int)HttpStatusCode.InternalServerError; objPaymentResonse.StatusDesc = ex.Message; objPaymentResonse.MessageId = ""; } return(objPaymentResonse); }
public List <RentBll> GetRentsByEmail(string email) { List <RentBll> rentsBll = new List <RentBll>(); foreach (Rent rent in _dataSource.GetRentsByEmail(email)) { rentsBll.Add(new RentBll(FactoryClass.CreateChild(_dataSource.GetOfferById(rent.OfferId)), rent.CustomerEmail, rent.InsuranceCase) { Cost = rent.Cost, EndDate = rent.EndDate, StartDate = rent.StartDate }); } return(rentsBll); }
public ActionResult Create(CommandModel cModel) { if (ModelState.IsValid) { var commandobj = FactoryClass.GetCommand(); commandobj.Id = cModel.Id; commandobj.Name = cModel.Name; commandobj.Usage = cModel.Usage; commandobj.Description = cModel.Description; _commandCollection.AddCommand(commandobj); return(RedirectToAction("Commands")); } else { return(View(cModel)); } }
public RentBll GetOpenRentByOfferId(RentParametersBll parameters) { Rent rent = _dataSource.GetOpenRentByOfferId(new RentParameters { CustomerEmail = parameters.CustomerEmail, OfferId = parameters.OfferId }); if (rent == null) { return(null); } OfferBll offerBll = FactoryClass.CreateChild(_dataSource.GetOfferById(parameters.OfferId)); return(new RentBll(offerBll, rent.CustomerEmail, rent.InsuranceCase) { StartDate = rent.StartDate, Id = rent.Id }); }
public void Add_ApiEmployeeAsParameter_ExpectedInsertedRow() { ApiEmployee item = new ApiEmployee(); item.aditional_info = "additional info from UnitTest"; item.aditional_service = "additional service from UnitTest"; item.another_building = "CheckAlt Building"; item.another_company = "CheckAlt Company"; item.cellphone = "777-777-7777"; item.email = "*****@*****.**"; item.fk_buildingaccess = 1; item.fk_companylist = 1; item.fk_hiredfor = 1; item.fullName = "Unit Test Phase 2"; item.hiringManagerEmail = "*****@*****.**"; item.initiationDate = DateTime.Now; item.restricted_access = ""; item.service_equipmentneeded = "Laptop"; item.startDate = DateTime.Now; IRepository <ApiEmployee> _repository = FactoryClass.MakeEmployeeRepository(); ApiEmployee employeerow = _repository.Add(item); Assert.IsTrue(employeerow.email == "*****@*****.**" && employeerow.service_equipmentneeded == "Laptop"); }
public Form1() { InitializeComponent(); factoryClass = new FactoryClass(); }
//метод который возвращает объект этого класса public FactoryClass Factory(int a, int b) { FactoryClass obj = new FactoryClass(); obj.alpha = a; obj.beta = b; return obj; }
public EmployeeDetailsController( ) { _repository = FactoryClass.MakeEmployeeDetailsRepository(); }
static void Main(string[] args) { Console.Clear(); int wrong = 3; int score = 0; Console.WriteLine("what is your Username?"); string Username = Console.ReadLine(); Console.WriteLine("what is your Password?"); string Password = Console.ReadLine(); Console.Clear(); while (wrong > 0) { Random random = new Random(); int whaa = 1; int value1 = random.Next(1, 10); int value2 = random.Next(1, 10); if (score >= 3) { whaa = 3; value1 = random.Next(2, 10); value2 = random.Next(2, 10); } if (score >= 6) { whaa = 2; value1 = random.Next(1, 20); value2 = random.Next(1, 20); } if (score >= 9) { whaa = 4; value1 = random.Next(3, 10); value2 = random.Next(3, 10); } FactoryClass factoryMethod = new FactoryClass(); Icalculations obj = factoryMethod.GetIcalculations(whaa); if (value1 < value2) { int temp = value2; value2 = value1; value1 = temp; } obj.calculate(value1, value2); Console.WriteLine($"{wrong} tries to go"); Console.WriteLine($"your current score is {score}"); Console.WriteLine("Enter Answer"); int num; int.TryParse(Console.ReadLine(), out num); if (num == value2 + value1 && whaa == 1 || num == value1 - value2 && whaa == 2 || num == value2 * value1 && whaa == 3 || num == value1 + (value1 * value2) - value1 && whaa == 4) { Console.Clear(); score++; } else { Console.Clear(); wrong--; if (wrong == 0) { Console.WriteLine($"Hello {Username}, Your final score was {score}, try again next time"); } } } }
public OfferBll GetOfferById(int id) { Offer offer = _dataSource.GetOfferById(id); return(FactoryClass.CreateChild(offer)); }
public BuildingController() { _repository = FactoryClass.MakeBuildingRepository(); }
public CompanyController() { _repository = FactoryClass.MakeCompanyRepository(); }
public BeingHiredForController( ) { _repository = FactoryClass.MakeBeingHiredForRepository(); }
private void button1_Click(object sender, EventArgs e) { //Init Button FactoryClass Init = new FactoryClass(); Universitate Univ = Init.GetInfoFromFilesAndCreatUniversitate(); Poli = Univ; }