public CalculateController(IFoodService food, UserManager<User> userManager, ICalculatorService calculator)
 {
     
     this.food = food;
     this.userManager = userManager;
     this.calculator = calculator;
 }
        public void TestPropertyInjection()

        {
            ICalculatorService calc = container.GetService(typeof(ICalculatorService)) as ICalculatorService;

            Assert.NotNull(calc);

            Assert.Equal(100, calc.X);
            Assert.Equal(200, calc.Y);

            Assert.Equal(2, calc.Add(1, 1));

            Assert.Equal(2, calc.Subtract(3, 1));

            Assert.Throws(typeof(KeyNotFoundException), () =>

            {
                container.GetService <ICalculatorService>("KeyNotFoundException");
            });
            Assert.Throws(typeof(KeyNotFoundException), () =>

            {
                container.GetService <ICalculatorService>("PropertyKeyNotFound");
            });
        }
Example #3
0
        public FormViewModel(IEventAggregator eventAggregator, IDataService dataService, ICalculationInput calculationInput, ICalculationOutput calculationOutput, ICalculatorService calculatorService)
        {
            _dataService     = dataService;
            _eventAggregator = eventAggregator;
            _eventAggregator.GetEvent <CalculationInputUpdated>().Subscribe(UpdateCalculationInput);
            _eventAggregator.GetEvent <CalculationOutputUpdated>().Subscribe(UpdateCalculationOutput);
            _calculationOutput = calculationOutput as CalculationOutput;
            _calculationInput  = calculationInput as CalculationInput;
            _calculatorService = calculatorService;

//#if DEBUG
//      CalculationInput.Personnel = "Stuart";
//      CalculationInput.Location = "Victoria";
//      CalculationInput.Action = "GIS Inspection";
//      CalculationInput.IsAlternatingCurrent = true;
//      CalculationInput.NominalVoltage = 15000;
//      CalculationInput.IsOpenAir = true;
//      CalculationInput.IsSolidGround = true;
//      CalculationInput.HasTransformer = true;
//      CalculationInput.PrimaryVoltage = 1000;
//      CalculationInput.XfmrImpedance = 5.75m;
//      CalculationInput.HasCable = true;
//      CalculationInput.ConductorLength = 100;
//      CalculationInput.ConductorPerPhase = 2;
//      CalculationInput.ConductorSizeId = 0;
//      CalculationInput.XfmrKVA = 1234;

//      CalculationInput.SourceFaultCurrent = 1000;
//      CalculationInput.EquipmentTypeId = 0;
//      CalculationInput.ArcDurationValue = 2;
//#endif

            FindEquipmentTripCurvesCommand = new DelegateCommand(FindEquipmentTripCurves);
            CalculateArcDurationCommand    = new DelegateCommand(CalculateArcDuration);
        }
        public void RelayAsyncMessage()
        {
            StubServiceHost.FindDefaultService <ICalculatorService>()
            .Setup(s => s.BeginMultiply(It.IsAny <XmlCalculatorRequest>(), It.IsAny <AsyncCallback>(), It.IsAny <object>()))
            .Returns(new StringStream(string.Format(CALCULATOR_RESPONSE_XML, 2)));

            ICalculatorService client = null;

            try
            {
                client = SimpleServiceClient <CalculatorService, ICalculatorService> .Create();

                var calculatorResult = Task <XmlCalculatorResponse> .Factory
                                       .FromAsync(client.BeginMultiply, client.EndMultiply, new XmlCalculatorRequest(CALCULATOR_REQUEST_XML), null)
                                       .Result;

                Assert.AreEqual(string.Format(CALCULATOR_RESPONSE_XML, 2), calculatorResult.RawXmlBody);
                client.Close();
            }
            catch (Exception)
            {
                if (client != null)
                {
                    client.Abort();
                }
                throw;
            }
        }
        /// <summary>
        /// maaş tipine göre kullanılacak arayüzü bulur
        /// </summary>
        /// <param name="salaryType"></param>
        /// <returns></returns>
        public ICalculatorService GetCalculatorService(SalaryType salaryType)
        {
            switch (salaryType)
            {
            case SalaryType.Fixed:
                _calculatorService = new FixedCalculator();
                break;

            case SalaryType.Daily:
                _calculatorService = new DailyCalculator();
                break;

            case SalaryType.FixedPlusOvertime:
                _overtimeCalculator       = new OvertimeCalculator();
                _calculatorServiceForPlus = new FixedCalculator();
                _calculatorService        = new SalaryPlusOvertimeCalculator(_overtimeCalculator, _calculatorServiceForPlus);
                break;

            case SalaryType.DailyPlusOvertime:
                _overtimeCalculator       = new OvertimeCalculator();
                _calculatorServiceForPlus = new DailyCalculator();
                _calculatorService        = new SalaryPlusOvertimeCalculator(_overtimeCalculator, _calculatorServiceForPlus);
                break;

            default:
                throw new NotImplementedException();
            }
            return(_calculatorService);
        }
        public void RelayCompositeMessage()
        {
            const string responseXml = "<CalculatorResponse xmlns=\"urn:services.stateless.be:unit:calculator\">" +
                                       "<s0:Result xmlns:s0=\"urn:services.stateless.be:unit:calculator\">one</s0:Result>" +
                                       "<s0:Result xmlns:s0=\"urn:services.stateless.be:unit:calculator\">two</s0:Result>" +
                                       "</CalculatorResponse>";

            StubServiceHost.FindDefaultService <ICalculatorService>()
            .Setup(s => s.Add(It.IsAny <XmlCalculatorRequest>()))
            .Returns(new StringStream(responseXml));

            ICalculatorService client = null;

            try
            {
                client = SimpleServiceClient <CalculatorService, ICalculatorService> .Create();

                var calculatorResult = client.Add(new XmlCalculatorRequest(CALCULATOR_REQUEST_XML));
                Assert.AreEqual(responseXml, calculatorResult.RawXmlBody);
                client.Close();
            }
            catch (Exception)
            {
                if (client != null)
                {
                    client.Abort();
                }
                throw;
            }
        }
        public void RelaySyncMessage()
        {
            StubServiceHost.FindDefaultService <ICalculatorService>()
            .Setup(s => s.Add(It.IsAny <XmlCalculatorRequest>()))
            .Returns(new StringStream(string.Format(CALCULATOR_RESPONSE_XML, 3)));

            ICalculatorService client = null;

            try
            {
                client = SimpleServiceClient <CalculatorService, ICalculatorService> .Create();

                var calculatorResult = client.Add(new XmlCalculatorRequest(CALCULATOR_REQUEST_XML));
                Assert.AreEqual(string.Format(CALCULATOR_RESPONSE_XML, 3), calculatorResult.RawXmlBody);
                client.Close();
            }
            catch (Exception)
            {
                if (client != null)
                {
                    client.Abort();
                }
                throw;
            }
        }
Example #8
0
        private static void RemoveVarFromMemory(ICalculatorService calculator)
        {
            Console.WriteLine("Enter name:");
            var name = Console.ReadLine();

            calculator.Clear(name);
        }
Example #9
0
 public MovieController(ILogger <MovieController> logger, IMovieService movieService, IMemoryCache cache, ICalculatorService calc)
 {
     _logger            = logger;
     _movieService      = movieService;
     _calculatorService = calc;
     _cache             = cache;
 }
Example #10
0
 public void SetUp()
 {
     //Arrange
     calculatorService   = A.Fake <ICalculatorService>();
     commandFactory      = A.Fake <ICommandFactory>();
     calculatorViewModel = new CalculatorViewModel(calculatorService, commandFactory);
 }
Example #11
0
        public void RelayCompositeMessage()
        {
            const string responseXml = "<CalculatorResponse xmlns=\"urn:services.stateless.be:unit:calculator\">" +
                                       "<s0:Result xmlns:s0=\"urn:services.stateless.be:unit:calculator\">one</s0:Result>" +
                                       "<s0:Result xmlns:s0=\"urn:services.stateless.be:unit:calculator\">two</s0:Result>" +
                                       "</CalculatorResponse>";

            _soapStub.As <ICalculatorService>()
            .Setup(s => s.Add(It.IsAny <XmlCalculatorRequest>()))
            .Returns(new StringStream(responseXml));

            ICalculatorService client = null;

            try
            {
                client = SoapClient <ICalculatorService> .For(_calculatorServiceHost.Endpoint);

                var calculatorResult = client.Add(new(CALCULATOR_REQUEST_XML));
                Assert.That(calculatorResult.RawXmlBody, Is.EqualTo(responseXml));
                client.Close();
            }
            catch (Exception)
            {
                client?.Abort();
                throw;
            }
        }
 public McBurgerRestaurant(ICalculatorService calculatorService, IPaymentService paymentService, ICookingService cookingService, IPrintService printService)
 {
     this.calculatorService = calculatorService;
     this.paymentService    = paymentService;
     this.cookingService    = cookingService;
     this.printService      = printService;
 }
 public ProductController(ILogger <ProductController> logger, IProductService productService, ICalculatorService calculatorService, IPersistenceService persistenceService)
 {
     _logger             = logger;
     _productService     = productService;
     _calculatorService  = calculatorService;
     _persistenceService = persistenceService;
 }
Example #14
0
        public void SetUp()
        {
            _serviceHost = CreateService();
            _serviceHost.Open();

            _client = CreateClient();
        }
Example #15
0
        public CalculatorSerivce_Test()
        {
            //var services = new ServiceCollection();


            //services.Configure<TierCountLimit>(System.Configuration.GetSection("TierCountLimit"));
            //services.AddTransient<ICalculatorService, CalculatorService>();
            //services.AddTransient<IUserTierService, UserTierService>();
            //services.AddTransient<IIAMService, IAMService>();
            //services.AddTransient<IValidationService, ValidationService>();

            //var serviceProvider = services.BuildServiceProvider();

            //_calculatorService = serviceProvider.GetService<ICalculatorService>();

            ////services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
            ////_dbContext = new DatabaseContext();
            ////_validationService = new ValidationService();
            ////httpContextAccessor = new HttpContextAccessor();
            ////_iamService = new IAMService(_dbContext, _validationService, );
            ////_userTierService = new UserTierService()
            ////_calculatorService = new CalculatorService();

            _validationService = new ValidationService();
            _calculatorService = new CalculatorService(_validationService);
        }
Example #16
0
 public CalculatorController(
     ICalculatorService calculator,
     ILogger <CalculatorController> logger)
 {
     _calculator = calculator;
     _logger     = logger;
 }
Example #17
0
        static void Main(string[] args)
        {
            Uri uri = new Uri(ConfigurationManager.AppSettings["CalculatorServiceAddress"]);

            BasicHttpBinding binding  = new BasicHttpBinding();
            EndpointAddress  endpoint = new EndpointAddress(uri);

            ChannelFactory <ICalculatorService> proxy = new ChannelFactory <ICalculatorService>(binding, endpoint);

            ICalculatorService calculatorService = proxy.CreateChannel();

            int result = calculatorService.Add(1, 2);

            Console.WriteLine(result);

            try
            {
                result = calculatorService.Divide(4, 0);
            }
            catch (FaultException <DivideByZeroFault> e)
            {
                Console.WriteLine($"{e.Detail.Code} {e.Detail.Error} {e.Detail.Description}");
            }

            Console.WriteLine("Press key to exit.");
            Console.ReadKey();
        }
Example #18
0
 private static void Calculate(ICalculatorService calculator)
 {
     Console.WriteLine("Enter expression:");
     var name = Console.ReadLine();
     var result = calculator.Calculate(name);
     Console.WriteLine("Result: {0}", result);
 }
Example #19
0
 public void CalculatorController_Setup()
 {
     _ratingDetailService  = new RatingDetailService();
     _occupationService    = new OccupationService(_ratingDetailService);
     _calculatorService    = new CalculatorService(_occupationService);
     _calculatorController = new CalculatorController(_calculatorService);
 }
Example #20
0
        static void Main(string[] args)
        {
            string url = "http://localhost:8080/CalculatorService";

            BasicHttpBinding binding  = new BasicHttpBinding();
            EndpointAddress  endpoint = new EndpointAddress(url);

            ChannelFactory <ICalculatorService> proxy = new ChannelFactory <ICalculatorService>(binding, endpoint);

            ICalculatorService client = proxy.CreateChannel();

            while (true)
            {
                Console.Write("Type numerator: ");

                if (int.TryParse(Console.ReadLine(), out int numerator))
                {
                    Console.Write("Type denominator: ");

                    if (int.TryParse(Console.ReadLine(), out int denominator))
                    {
                        try
                        {
                            int result = client.Divide(numerator, denominator);
                            Console.WriteLine($"Result: {result}");
                        }
                        catch (FaultException e)
                        {
                            Console.WriteLine(e.Message);
                        }
                    }
                }
            }
        }
        public void TestInitialize()
        {
            _providerMock = new Mock <IMathExpressionProvider>();
            _providerMock.Setup(x => x.Get(It.IsAny <MathOperations>())).Returns((x, y) => 3);

            _service = new CalculatorService(_providerMock.Object);
        }
 public RegisterService(
     ILab08ParkingLotUnitOfWork lab08ParkingLotUnitOfWork,
     ICalculatorService calculatorService)
 {
     _lab08ParkingLotUnitOfWork = lab08ParkingLotUnitOfWork;
     _calculatorService         = calculatorService;
 }
Example #23
0
        public void RelayAsyncMessage()
        {
            _soapStub.As <ICalculatorService>()
            .Setup(s => s.BeginMultiply(It.IsAny <XmlCalculatorRequest>(), It.IsAny <AsyncCallback>(), It.IsAny <object>()))
            .Returns(new StringStream(string.Format(CALCULATOR_RESPONSE_XML, 2)));

            ICalculatorService client = null;

            try
            {
                client = SoapClient <ICalculatorService> .For(_calculatorServiceHost.Endpoint);

                var calculatorResult = Task <XmlCalculatorResponse> .Factory
                                       .FromAsync(client.BeginMultiply, client.EndMultiply, new XmlCalculatorRequest(CALCULATOR_REQUEST_XML), null)
                                       .Result;

                Assert.That(calculatorResult.RawXmlBody, Is.EqualTo(string.Format(CALCULATOR_RESPONSE_XML, 2)));
                client.Close();
            }
            catch (Exception)
            {
                client?.Abort();
                throw;
            }
        }
Example #24
0
 public ParkingController(
     IRegisterService registerService,
     ICalculatorService calculatorService)
 {
     _registerService   = registerService;
     _calculatorService = calculatorService;
 }
Example #25
0
        public void SetUp()
        {
            try
            {
                Tester = new ServiceTester <CalculatorServiceHost>
                {
                    CommunicationKernel = new MicrodotInitializer(
                        "CalculatorServiceCommLayer",
                        new ConsoleLogLoggersModules(),
                        k =>
                    {
                        k.Rebind <ICacheRevoker>().ToConstant(_fakeRevokingManager);
                        k.Rebind <IRevokeListener>().ToConstant(_fakeRevokingManager);
                        k.Rebind <ICertificateLocator>().To <DummyCertificateLocator>().InSingletonScope();
                    }
                        ).Kernel
                };

                Service            = Tester.GetServiceProxy <ICalculatorService>();
                ServiceWithCaching = Tester.GetServiceProxyWithCaching <ICalculatorService>();
                ProxyProvider      = Tester.GetServiceProxyProvider("CalculatorService");
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
Example #26
0
 public void Setup()
 {
     _lab08ParkingLotUnitOfWork = new Mock <ILab08ParkingLotUnitOfWork>();
     _vehicleRatesService       = new Mock <IVehicleRatesService>();
     _calculatorService         = new CalculatorService(_lab08ParkingLotUnitOfWork.Object, _vehicleRatesService.Object);
     _registerService           = new RegisterService(_lab08ParkingLotUnitOfWork.Object, _calculatorService);
 }
 public PointOfSaleTerminal()
 {
     _productProvider   = new ProductProvider();
     _discountProvider  = new DiscountProvider();
     _cart              = new Cart();
     _calculatorService = new CalculatorService(_productProvider, _discountProvider);
 }
Example #28
0
        static void Main(string[] args)
        {
            try
            {
                Environment.SetEnvironmentVariable("GIGYA_CONFIG_ROOT", Environment.CurrentDirectory);
                Environment.SetEnvironmentVariable("GIGYA_CONFIG_PATHS_FILE", "");
                Environment.SetEnvironmentVariable("GIGYA_ENVVARS_FILE", Environment.CurrentDirectory);
                Environment.SetEnvironmentVariable("REGION", "us1");
                Environment.SetEnvironmentVariable("ZONE", "us1a");
                Environment.SetEnvironmentVariable("ENV", "dev");

                CurrentApplicationInfo.Init("CalculatorService.Client");

                var kernel = new StandardKernel();
                kernel.Load <MicrodotModule>();
                kernel.Load <NLogModule>();

                ICalculatorService calculatorService = kernel.Get <ICalculatorService>();
                int sum = calculatorService.Add(2, 3).Result;
                Console.WriteLine($"Sum: {sum}");
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex);
            }
        }
 public ExpectedValueForm(ICalculatorService calculator)
 {
     this.calculator            = calculator;
     expectedValueNumberOfDice  = 1;
     expectedValueNumberOfSides = 20;
     expectedValue = 10.5m;
     InitializeComponent();
 }
Example #30
0
        public void TestFixtureSetUp()
        {
            _serviceTester = new ServiceTester <CalculatorServiceHost>();

            _serviceProxy = _serviceTester.GetServiceProxy <ICalculatorService>();

            _flumeQueue = (SpyEventPublisher)_serviceTester.Host.Kernel.Get <IEventPublisher>();
        }
Example #31
0
        private static void Calculate(ICalculatorService calculator)
        {
            Console.WriteLine("Enter expression:");
            var name   = Console.ReadLine();
            var result = calculator.Calculate(name);

            Console.WriteLine("Result: {0}", result);
        }
Example #32
0
 private static void Divide(ICalculatorService calculator)
 {
     Console.WriteLine("Enter a:");
     var a = ReadDouble();
     Console.WriteLine("Enter b:");
     var b = ReadDouble();
     var result = calculator.Divide(a, b);
     Console.WriteLine("Result: " + (Double.IsInfinity(result) ? "infinity" : Convert.ToString(result)));
 }
Example #33
0
 private static void Add(ICalculatorService calculator)
 {
     Console.WriteLine("Enter a:");
     var a = ReadDouble();
     Console.WriteLine("Enter b:");
     var b = ReadDouble();
     var result = calculator.Add(a, b);
     Console.WriteLine("Result: " + result);
 }
Example #34
0
        public void TestMultiply()
        {
            IApplicationContext appContext = ContextRegistry.GetContext();

            calculatorService = (ICalculatorService)appContext.GetObject("calculatorService");

            double expected = 2 * 2;

            double actual = calculatorService.multiply(2, 2);

            Assert.AreEqual(expected, actual, "Failed");
        }
Example #35
0
 private static void Close(ICalculatorService calculator)
 {
     _willClose = true;
 }
Example #36
0
 private static void StartService()
 {
     myServiceHost = new ServiceHost(typeof(CalculatorService.CalculatorService));
     myServiceHost.Open();
 }
Example #37
0
 private static void SaveVarInMemory(ICalculatorService calculator)
 {
     Console.WriteLine("Enter name:");
     var name = Console.ReadLine();
     Console.WriteLine("Enter value:");
     var value = ReadDouble();
     calculator.Save(name, value);
 }
Example #38
0
 private static void RemoveVarFromMemory(ICalculatorService calculator)
 {
     Console.WriteLine("Enter name:");
     var name = Console.ReadLine();
     calculator.Clear(name);
 }
Example #39
0
 private static void RemoveAllVarsFromMemory(ICalculatorService calculator)
 {
     calculator.ClearAll();
 }