Inheritance: ModuleRules
    public static Something CreateSomething()
    {
        var something = new Something();

        listOfSomethings.Add(something);
        return(something);
    }
示例#2
0
    public async Task Http_Respond_On_Valid_Data()
    {
        //Arrange
        var someResult = new SomeResultModel()
        {
            //...
        };
        var mock = new Mock <ISomeDependency>();

        mock.Setup(_ => _.dbCall()).ReturnsAsync(someResult);
        Something.Factory = () => return(mock.Object);

        var postParam = new Dictionary <string, StringValues>();

        postParam.Add("param", "value");
        var request = new DefaultHttpRequest(new DefaultHttpContext())
        {
            Query = new QueryCollection(postParam)
        };
        //Act
        var response = (OkObjectResult)await Something.Run(request, logger);

        //Assert
        string stringResponse = (String)response.Value;

        Assert.Equal("XKCD", stringResponse);
    }
        public async Task <ActionResult <Something> > Post(Something something)
        {
            var entry  = _context.Somethings.Add(something);
            var result = await _context.SaveChangesAsync();

            return(CreatedAtAction(nameof(GetById), new { id = something.Id }, something));
        }
        public void SerializeTest()
        {
            var formatter = new EfficientBinaryFormatter();
            var o         = new object();
            var s         = new Something()
            {
                d = 3.0, i = 1, s = "foo"
            };

            using (var ms = new MemoryStream()) {
                Assert.Throws <ArgumentNullException>(() => formatter.Serialize(ms, null));
                Assert.DoesNotThrow(() => formatter.Serialize(ms, "abc"));
                Assert.DoesNotThrow(() => formatter.Serialize(ms, 1));
                Assert.DoesNotThrow(() => formatter.Serialize(ms, 1.0));
                Assert.DoesNotThrow(() => formatter.Serialize(ms, o));
                Assert.DoesNotThrow(() => formatter.Serialize(ms, 1.2d));
                Assert.DoesNotThrow(() => formatter.Serialize(ms, s));
                using (var ms2 = new MemoryStream()) {
                    Assert.DoesNotThrow(() => formatter.Serialize(ms2, "abc"));
                    Assert.DoesNotThrow(() => formatter.Serialize(ms2, 1));
                    Assert.DoesNotThrow(() => formatter.Serialize(ms2, 1.0));
                    Assert.DoesNotThrow(() => formatter.Serialize(ms2, o));
                    Assert.DoesNotThrow(() => formatter.Serialize(ms2, 1.2d));
                    Assert.DoesNotThrow(() => formatter.Serialize(ms2, s));

                    Assert.AreEqual(ms.ToArray(), ms2.ToArray());
                }
            }
        }
示例#5
0
        private void BtnLogin_Click(object sender, RoutedEventArgs e)
        {
            TxtID_TextChanged(null, null);
            TxtPassword_PasswordChanged(null, null);
            if (errID.Visibility == Visibility.Visible || errPassword.Visibility == Visibility.Visible)
            {
                return;
            }
            int id = Convert.ToInt32(txtID.Text);

            if (clr.Login(id, Something.MD5Encrypt(txtPassword.Password)) == 1)
            {
                parentWindow.user = clr.QueryProfile(id);
                if (parentWindow.user.privilege == 1)
                {
                    parentWindow.HideAnimation();
                    parentWindow.GotoUser(0);
                }
                else if (parentWindow.user.privilege == 2)
                {
                    parentWindow.GotoAdmin(0);
                }
            }
            else
            {
                Dialogs.Dialog dg = new Dialogs.Dialog("", TryFindResource("pglog.failed") as string);
                dg.ShowDialog();
            }
        }
示例#6
0
        public void validate_fail_no_value()
        {
            Assert.Throws <RulesExceptionCollection>(() =>
            {
                try
                {
                    var something = new Something();
                    something.Elses.Add(new Else {
                        Against = new List <Again> {
                            new Again()
                        }
                    });
                    something.Validate();
                }
                catch (RulesExceptionCollection ex)
                {
                    var somethingRulesException = ex.RulesExceptions.Single(x => x.TypeName == typeof(Something).Name);
                    Assert.Single(somethingRulesException.ErrorMessages);
                    Assert.Equal(6, ex.RulesExceptions.Count);
                    var exceptionDto = ex.GetRulesExceptionDto();

                    Assert.Single(exceptionDto.ErrorMessages);
                    Assert.Equal(3, exceptionDto.Errors.Count);
                    Assert.Single(exceptionDto.RulesExceptionListContainers);
                    Assert.Single(exceptionDto.RulesExceptionListContainers[0].RulesExceptionListContainers);
                    Assert.Equal(2, exceptionDto.RulesExceptionListContainers[0].Errors.Count());
                    Assert.Single(exceptionDto.RulesExceptionListContainers[0].RulesExceptionListContainers.Where(x => x.IsRoot));
                    Assert.Single(exceptionDto.RulesExceptionListContainers[0].RulesExceptionListContainers.Single(x => x.IsRoot).Errors);

                    throw;
                }
            });
        }
        private void button1_Click(object sender, EventArgs e)
        {
            string    aValue = String.Empty;
            Something a      = new Something();

            a.SomeThingElse = aValue;
        }
示例#8
0
 static Something[] CreateArray(int n)
 {
     Something[] array = new Something[n];
     for (int i = 0; i < n; i++)
     {
         if (i % 2 == 0)
         {
             double volume;
             if (!double.TryParse(Console.ReadLine(), out volume) || volume < 0 || volume - 1 > Double.Epsilon)
             {
                 Console.WriteLine("Incorrect input!");
                 continue;
             }
             array[i] = new Ashes(volume);
             ashes.Add((Ashes)array[i]);
         }
         else
         {
             double weight;
             if (!double.TryParse(Console.ReadLine(), out weight) || weight < 0 || weight - 2 > Double.Epsilon)
             {
                 Console.WriteLine("Incorrect input!");
                 continue;
             }
             array[i] = new Lentil(weight);
             lentils.Add((Lentil)array[i]);
         }
     }
     return(array);
 }
示例#9
0
        public void SetUp()
        {
            _getSomething          = new GetSomething();
            _getSomethingCacheable = new GetSomethingCacheable();
            _something             = new Something();

            _queryHandler = new Mock <IQueryHandlerAsync <GetSomething, Something> >();
            _queryHandler
            .Setup(x => x.HandleAsync(_getSomething))
            .ReturnsAsync(_something);

            _handlerResolver = new Mock <IHandlerResolver>();
            _handlerResolver
            .Setup(x => x.ResolveHandler <IQueryHandlerAsync <GetSomething, Something> >())
            .Returns(_queryHandler.Object);

            _cacheManager = new Mock <ICacheManager>();
            _cacheManager
            .Setup(x => x.GetOrSetAsync(_getSomethingCacheable.CacheKey, It.IsAny <int>(), It.IsAny <Func <Task <Something> > >()))
            .ReturnsAsync(_something);

            _cacheOptions = new Mock <IOptions <CacheOptions> >();
            _cacheOptions
            .Setup(x => x.Value)
            .Returns(new CacheOptions());

            _sut = new QueryProcessor(_handlerResolver.Object, _cacheManager.Object, _cacheOptions.Object);
        }
        public void DeserializeTest()
        {
            var formatter = new EfficientBinaryFormatter();
            var s         = new Something()
            {
                d = 3.0, i = 1, s = "foo"
            };
            var o = new OtherThing(100);

            using (var ms = new MemoryStream()) {
                formatter.Serialize(ms, "test");
                formatter.Serialize(ms, 1);
                formatter.Serialize(ms, s);
                formatter.Serialize(ms, o);
                ms.Seek(0, SeekOrigin.Begin);
                Assert.AreEqual(formatter.Deserialize(ms), "test");
                Assert.AreEqual(formatter.Deserialize(ms), 1);
                Assert.AreEqual(s, formatter.Deserialize(ms));
                var other = (OtherThing)formatter.Deserialize(ms);
                Assert.AreEqual(other.self, other);
                Assert.AreEqual(other.b, true);
                Assert.AreEqual(other.s, o.s);
                Assert.AreEqual(other.arr1, o.arr1);
                Assert.AreEqual(other.arr2, o.arr2);
                Assert.AreEqual(other.arr3, o.arr3);
                Assert.AreEqual(other.arr4[0], other.self);
                Assert.AreNotEqual(other.i, o.i);
            }
        }
示例#11
0
        private void BtnQuery_Click(object sender, RoutedEventArgs e)
        {
            if (txtLoc1.Text == "" || txtLoc2.Text == "" || txtLoc1.Text.Contains(" ") || txtLoc2.Text.Contains(" ") || date.SelectedDate == null)
            {
                Dialogs.Dialog dg = new Dialogs.Dialog("", TryFindResource("pgquery.failed") as string);
                dg.ShowDialog();
                return;
            }
            string catalog = "";

            foreach (CheckBox ch in stack.Children)
            {
                if (ch.Content.ToString().Length == 1 && ch.IsChecked == true)
                {
                    catalog += ch.Content;
                }
            }
            List <Ticket> list = clr.QueryTicket(txtLoc1.Text, txtLoc2.Text, ((DateTime)(date.SelectedDate)).ToString("yyyy-MM-dd"), catalog, chTransfer.IsChecked == true);

            Something.Merge(list);
            lst.Items.Clear();
            if (list != null && list.Count > 0)
            {
                foreach (Ticket t in list)
                {
                    lst.Items.Add(new ListItem(t, clr, parentWindow.user.ID, 0));
                }
            }
        }
示例#12
0
    IEnumerator SomethingSave()
    {
        List <Something> TempList = new List <Something>();
        Something        st;

        for (int i = 0; i < SomethingList.Count; i++)
        {
            //recovery = InventoryManager.Instance.FData.FoodList[i].Recovery;
            //name = InventoryManager.Instance.FData.FoodList[i].Name;

            //count = InventoryManager.Instance.FData.FoodList[i].Count;

            st = new Something(SomethingList[i].Name, SomethingList[i].Perfection, SomethingList[i].Grade);

            TempList.Add(st);
        }


        JsonData SomethingJson = JsonMapper.ToJson(TempList);

        if (EndingEvent.Instance.path == Application.persistentDataPath)
        {
            File.WriteAllText(Application.persistentDataPath + "/Something.json", SomethingJson.ToString());
        }
        else
        {
            File.WriteAllText(EndingEvent.Instance.path + "/Resources/Something.json", SomethingJson.ToString());
        }



        yield return(null);
    }
示例#13
0
    public MainWindow()
    {
        InitializeComponent();
        Something st = new Something();

        this.DataContext = st;
    }
示例#14
0
        private void BtnQuery_Click(object sender, RoutedEventArgs e)
        {
            string catalog = "";

            foreach (CheckBox ch in stack.Children)
            {
                if (ch.Content.ToString().Length == 1 && ch.IsChecked == true)
                {
                    catalog += ch.Content;
                }
            }
            List <Ticket> list = new List <Ticket>();

            for (DateTime d = (DateTime)date1.SelectedDate, de = (DateTime)date2.SelectedDate; d <= de; d = d.AddDays(1))
            {
                list.AddRange(clr.QueryOrder(parentWindow.user.ID, d.ToString("yyyy-MM-dd"), catalog));
            }
            Something.Merge(list);
            lst.Items.Clear();
            if (list != null && list.Count > 0)
            {
                foreach (Ticket t in list)
                {
                    lst.Items.Add(new ListItem(t, clr, parentWindow.user.ID, 1));
                }
            }
        }
示例#15
0
 private void BuildTree(List <Something> list, Something s = null)
 {
     list.Add(s);
     foreach (Something ss in s.Followers.OrderBy(sss => sss.Layer.Priority))
     {
         BuildTree(list, ss);
     }
 }
 public bool Equals(Something s)
 {
     if (s == null)
     {
         return(false);
     }
     return(this.Id == s.Id && string.Equals(this.Name, s.Name));
 }
示例#17
0
        public void GetWithDynamicAutoCast()
        {
            var classWithSome = new ClassWithSomething();
            // Necesita referencia Microsoft.CSharp, para utilizar modelBinder
            Something some = classWithSome.Something;

            Assert.IsNotNull(some);
        }
示例#18
0
        public void roundtrip_Constant_object()
        {
            ISomething         value = new Something();
            ConstantExpression expr  = Expression.Constant(value);
            var result = (ConstantExpression)SerializableExpression.ToExpression(SerializableExpression.FromExpression(expr, iftFactory));

            AssertExpressions.AreEqual(result, expr);
        }
示例#19
0
        public void ThrowsAnExcpetion_IfDividingByZero()
        {
            var x   = 1;
            var y   = 0;
            var sut = new Something();

            Assert.Throws <DivideByZeroException>(() => sut.DivideNumbers(x, y));
        }
 public void Should_not_die_when_trying_to_sub_for_an_event_handler()
 {
     var sut = new Something();
     var handler = Substitute.For<EventHandler<SomethingEventArgs>>();
     sut.SomethingHappened += handler;
     sut.DoSomething();
     handler.Received().Invoke(sut, Arg.Is<SomethingEventArgs>(e => e.Somethings == 2));
 }
 public void Initialize( )
 {
     _finder    = Substitute.For <IArgumentNullExceptionFinder> ( );
     _generator = Substitute.For <IArgumentsGenerator> ( );
     _typeClass = typeof(Something);
     _typeInt   = typeof(int);
     _instance  = new Something(new SomethingElse( ));
 }
示例#22
0
        private string DoSomeWork()
        {
            var something = new Something(7);

            var result = GetAStringFor(something);

            return(result.Replace('a', 'e'));
        }
示例#23
0
        public void roundtrip_Constant_object()
        {
            ISomething value = new Something();
            ConstantExpression expr = Expression.Constant(value);
            var result = (ConstantExpression)SerializableExpression.ToExpression(null, SerializableExpression.FromExpression(expr, null, iftFactory, null, null), iftFactory);

            AssertExpressions.AreEqual(result, expr);
        }
示例#24
0
        public void SetUp()
        {
            _createSomething  = new CreateSomething();
            _somethingCreated = new SomethingCreated();
            _getSomething     = new GetSomething();
            _something        = new Something();
            _createAggregate  = new CreateAggregate();

            _commandSenderAsync = new Mock <ICommandSenderAsync>();
            _commandSenderAsync
            .Setup(x => x.SendAsync(_createSomething))
            .Returns(Task.CompletedTask);
            _commandSenderAsync
            .Setup(x => x.SendAsync <IDomainCommand, IAggregateRoot>(_createAggregate))
            .Returns(Task.CompletedTask);
            _commandSenderAsync
            .Setup(x => x.SendAndPublishAsync(_createSomething))
            .Returns(Task.CompletedTask);
            _commandSenderAsync
            .Setup(x => x.SendAndPublishAsync <IDomainCommand, IAggregateRoot>(_createAggregate))
            .Returns(Task.CompletedTask);

            _commandSender = new Mock <ICommandSender>();
            _commandSender
            .Setup(x => x.Send(_createSomething));
            _commandSender
            .Setup(x => x.Send <IDomainCommand, IAggregateRoot>(_createAggregate));
            _commandSender
            .Setup(x => x.SendAndPublish(_createSomething));
            _commandSender
            .Setup(x => x.SendAndPublish <IDomainCommand, IAggregateRoot>(_createAggregate));

            _eventPublisherAsync = new Mock <IEventPublisherAsync>();
            _eventPublisherAsync
            .Setup(x => x.PublishAsync(_somethingCreated))
            .Returns(Task.CompletedTask);

            _eventPublisher = new Mock <IEventPublisher>();
            _eventPublisher
            .Setup(x => x.Publish(_somethingCreated));

            _queryDispatcherAsync = new Mock <IQueryProcessorAsync>();
            _queryDispatcherAsync
            .Setup(x => x.ProcessAsync <IQuery, Something>(_getSomething))
            .ReturnsAsync(_something);

            _queryDispatcher = new Mock <IQueryProcessor>();
            _queryDispatcher
            .Setup(x => x.Process <IQuery, Something>(_getSomething))
            .Returns(_something);

            _sut = new Dispatcher(_commandSenderAsync.Object,
                                  _commandSender.Object,
                                  _eventPublisherAsync.Object,
                                  _eventPublisher.Object,
                                  _queryDispatcherAsync.Object,
                                  _queryDispatcher.Object);
        }
示例#25
0
        public void roundtrip_Constant_interface()
        {
            ISomething         value = new Something();
            ConstantExpression expr  = Expression.Constant(value, typeof(ISomething));
            var result = (ConstantExpression)SerializableExpression.ToExpression(SerializableExpression.FromExpression(expr, iftFactory));

            AssertExpressions.AreEqual(result, expr);
            Assert.That(result.Type, Is.EqualTo(typeof(ISomething)));
        }
        public void Should_not_die_when_trying_to_sub_for_an_event_handler()
        {
            var sut     = new Something();
            var handler = Substitute.For <EventHandler <SomethingEventArgs> >();

            sut.SomethingHappened += handler;
            sut.DoSomething();
            handler.Received().Invoke(sut, Arg.Is <SomethingEventArgs>(e => e.Somethings == 2));
        }
示例#27
0
            public TradeAction ActionPerformed(Somebody processor, Something processedObject)
            {
                TradeAction action = (TradeAction) New();
                action.Processor = processor;
                action.ProcessedObject = processedObject;
                action.When = DateTime.Now;

                return action;
            }
示例#28
0
        public void roundtrip_Constant_interface()
        {
            ISomething value = new Something();
            ConstantExpression expr = Expression.Constant(value, typeof(ISomething));
            var result = (ConstantExpression)SerializableExpression.ToExpression(null, SerializableExpression.FromExpression(expr, null, iftFactory, null, null), iftFactory);

            AssertExpressions.AreEqual(result, expr);
            Assert.That(result.Type, Is.EqualTo(typeof(ISomething)));
        }
示例#29
0
 public void ForAllStrings()
 {
     var thing = new Something { MyIntProp = 42, MyStringProp = "ne string" };
     var inspector = Inspect.This(thing);
     var list = new List<object>();
     inspector.ForAll(pi => pi.PropertyType == typeof(string), list.Add);
     Assert.Equal(1, list.Count);
     Assert.Equal("ne string", list[0]);
 }
示例#30
0
    static void Main(string[] Args)
    {
        var something = new Something();

        Console.WriteLine(something.Name);

        something.Name = "AAA";
        Console.WriteLine(something.Name);
    }
    private static void Main(string[] args)
    {
        var something = new Something();

        something.ComputeValue(13);
        something.ComputeValue(DateTime.Now);
        something.ComputeValue(DayOfWeek.Monday);
        Console.ReadKey();
    }
示例#32
0
        public void InterfaceImplementations()
        {
            var o = new Something();

            Equal(o.Bar, "Bar");
            Equal(((ISomething)o).Bar, "Bar");
            Equal(o.Foo(), 42);
            Equal(((ISomething)o).Foo(), 42);
        }
    static void Main(string[] args)
    {
        Something something = new Something();

        Foo(something);
        Console.ReadKey(true);
        GC.Collect();
        Console.ReadKey(true);
    }
示例#34
0
        public void CanRoundtripSomething()
        {
            var superiolizer = new Superiolizer();
            var something    = new Something("hej med dig");

            var roundtrippedSomething = superiolizer.Roundtrip(something);

            Assert.That(roundtrippedSomething.Text, Is.EqualTo("hej med dig"));
        }
示例#35
0
 public void Initialize( )
 {
     _creator       = Substitute.For <ISutInstanceCreator> ( );
     _lazyCreator   = Substitute.For <ISutLazyInstanceCreator> ( );
     _generator     = Substitute.For <IArgumentsGenerator> ( );
     _typeClass     = typeof(Something);
     _typeLazyClass = typeof(Lazy <Something>);
     _class         = new Something(new SomethingElse( ));
     _lazyClass     = new Lazy <Something> (() => new Something(new SomethingElse( )));
 }
示例#36
0
 public void ForAllPrimitives()
 {
     var thing = new Something {MyIntProp = 42, MyStringProp = "ne string"};
     var inspector = Inspect.This(thing);
     var list = new List<object>();
     inspector.ForAllPrimitives(list.Add);
     Assert.Equal(2, list.Count);
     Assert.Equal(42, list[0]);
     Assert.Equal("ne string", list[1]);
 }
示例#37
0
 public void CanSerializeNull()
 {
     var expected = new Something
     {
         Else = null
     };
     Serialize(expected);
     Reset();
     var actual = Deserialize<Something>();
     Assert.Equal(expected, actual);
 }
示例#38
0
 public void ForAll()
 {
     var somethingElse = new SomethingElse();
     var thing = new Something { MyIntProp = 42, MyStringProp = "ne string", MySomethingElse = somethingElse};
     var inspector = Inspect.This(thing);
     var list = new List<object>();
     inspector.ForAll(list.Add);
     Assert.Equal(3, list.Count);
     Assert.Contains(42, list);
     Assert.Contains("ne string", list);
     Assert.Contains(somethingElse, list);
 }
示例#39
0
        public void CanSerializeObject()
        {
            var expected = new Something
            {
                BoolProp = true,
                Int32Prop = 123,
                NullableInt32PropHasValue = 888,
                StringProp = "hello"
            };

            Serialize(expected);
            Reset();
            var actual = Deserialize<Something>();
            Assert.Equal(expected, actual);
        }
示例#40
0
 public void CanSerializePolymorphicObject()
 {
     var expected = new Something
     {
         Else = new OtherElse
         {
             Name = "Foo",
             More = "Bar"
         }
     };
     Serialize(expected);
     Reset();
     var actual = Deserialize<Something>();
     Assert.AreEqual(expected, actual);
 }
示例#41
0
            /// <summary>
            /// Returns the first action of the given kind, between the processor and the processedObject.
            /// </summary>
            /// <param name="kind"></param>
            /// <param name="processor"></param>
            /// <param name="processedObject"></param>
            /// <returns></returns>
            public TradeAction GetFirst(TradeAction.Kind kind, Somebody processor, Something processedObject)
            {
                ICollection<Persistent> result = kind.FindMany("Processor = {0} AND ProcessedObject = {1}", new Object[] { processor, processedObject });
                TradeAction first = null;

                foreach (TradeAction action in result)
                {
                    if (first == null || action.When < first.When)
                    {
                        first = action;
                    }
                }

                return first;
            }
示例#42
0
        public void TestMethod2()
        {
            ISomething something = new Something();
            var tasks = new List<Task>();
            var rwlock = new ReaderWriterLockSlim();

            for (var i = 0; i < 100; i++)
            {
                // These threads should never see "nothing"....
                tasks.Add(Task.Run(() =>
                {
                    for (var x = 0; x < 1000000; x++)
                    {
                        rwlock.EnterReadLock();
                        try
                        {
                            Thread.Sleep(100);
                            Assert.That(something.IsNothing, Is.False);
                        }
                        finally
                        {
                            rwlock.ExitReadLock();
                        }
                    }
                }));
            }

            // ... even though this one keeps setting it to nothing
            tasks.Add(Task.Run(() =>
            {
                for (var x = 0; x < 1000000; x++)
                {
                    rwlock.EnterWriteLock();
                    try
                    {
                        something = new Nothing();
                        Thread.Sleep(100);
                        something = new Something();
                    }
                    finally
                    {
                        rwlock.ExitWriteLock();
                    }
                }
            }));

            Task.WhenAll(tasks).Wait();
        }
        public void TestMethod1()
        {
            var checkPoint = dotMemory.Check();

            var s = new Something();
            var t = new Something[5];

            dotMemory.Check(memory =>
            {
                Assert.AreEqual(2, memory.GetDifference(checkPoint)
                    .GetNewObjects().GetObjects(where => where.Namespace.Like("IntelliTestAndUnitTesting.DotMemoryTests")).ObjectsCount);
            });

            Console.WriteLine(s);

        }
示例#44
0
 public void CanSerializeObjects()
 {
     var expected1 = new Something
     {
         StringProp = "First"
     };
     var expected2 = new Something
     {
         StringProp = "Second"
     };
     var expected3 = new Something
     {
         StringProp = "Last"
     };
     Serialize(expected1);
     Serialize(expected2);
     Serialize(expected3);
     Reset();
     Assert.Equal(expected1, Deserialize<Something>());
     Assert.Equal(expected2, Deserialize<Something>());
     Assert.Equal(expected3, Deserialize<Something>());
 }
示例#45
0
 public void SetMedia(Something media)
 {
     SetToWhat(media);
 }
            /// <summary>
            /// 
            /// </summary>
            /// <param name="wantedType"></param>
            /// <param name="includedIn"></param>
            /// <param name="persistentObject"></param>
            /// <param name="percent"></param>
            /// <param name="quantity"></param>
            /// <param name="validFrom"></param>
            /// <param name="validTo"></param>
            /// <returns></returns>
            public CompensationProvision NewRelativeDeduction(
                CompensationProvision.Kind wantedType,
                AgreedCompensation includedIn,
                Something persistentObject,
                Decimal percent,
                Decimal quantity,
                DateTime validFrom,
                DateTime validTo)
            {
                //Instantiate the new charge.
                CompensationProvision compensationProvision = NewCompensationProvision(
                    wantedType,
                    persistentObject,
                    quantity,
                    validFrom,
                    validTo);

                //Initiate
                compensationProvision.SetAppliesTo(persistentObject);
                compensationProvision.SetAgreedCompensation(includedIn);
                compensationProvision.AddPercent = -percent;
                compensationProvision.IsRelative = true;
                return compensationProvision;
            }
示例#47
0
 public void SetParticipantKind(Something.Kind kind)
 {
     SetWhatIs(kind);
 }
            private IEnumerable<CompensationProvision> GetOffers(
                Something something)
            {
                SqlEnumerator<CompensationProvision> e = Sql.GetEnumerator<CompensationProvision>(
                    string.Format("SELECT cod FROM {0} cod WHERE cod.AppliesTo=VAR({1},something)",
                    Kind.GetInstance<CompensationProvision.Kind>().FullInstanceClassName,
                        something.FullClassName));
                e.SetVariable("something", something);

                // By using yield return we make sure that the enumerator is disposed
                foreach (var cp in e)
                {
                    yield return cp;
                }
            }
            /// <summary>
            /// 
            /// </summary>
            /// <param name="newKind"></param>
            /// <param name="persistentObject"></param>
            /// <param name="conditionQuantity"></param>
            /// <param name="validFrom"></param>
            /// <param name="validTo"></param>
            /// <returns></returns>
            public CompensationProvision NewCompensationProvision(
                CompensationProvision.Kind newKind,
                Something persistentObject,
                Decimal conditionQuantity,
                DateTime validFrom,
                DateTime validTo)
            {
                CompensationProvision compensationProvision;
                //New instance of the specified type.
                if (newKind != null)
                {
                    compensationProvision = (CompensationProvision)newKind.New();
                }
                else
                {
                    compensationProvision = new CompensationProvision();
                }

                //Initiate.
                compensationProvision.ConditionQuantity = conditionQuantity;
                compensationProvision.SetAppliesTo(persistentObject);
                compensationProvision.ValidFrom = validFrom;
                compensationProvision.ValidTo = validTo;
                compensationProvision.IsClosed = false;

                return compensationProvision;
            }
示例#50
0
 public DepartmentHasWord(Word word, Something wordOwner, WordIndexAttribute.Kind attrKind)
     : base(word, wordOwner, attrKind)
 {
 }
        public void Sample_test_for_a_subject_that_uses_a_substitute_with_out_arguments()
        {
            var lookup = Substitute.For<ILookupStrings>();
            var something = new Something(lookup);

            var key = "key";
            string value;
            lookup.TryGet(key, out value).Returns(x => { x[1] = "test"; return true; });

            Assert.That(something.GetValue(key), Is.EqualTo("test"));
            Assert.That(something.GetValue("diff key"), Is.EqualTo("none"));
        }
 public SomethingElse(Something something)
 {
     MySomething = something;
 }
        public void SerializeWrappingErrorsAndErrorHandling()
        {
            var serialiser = JsonSerializer.Create(new JsonSerializerSettings() { });

            Something s = new Something
            {
                RootSomethingElse = new RootSomethingElse
                {
                    SomethingElse = new SomethingElse()
                }
            };
            RootThing r = new RootThing
            {
                Something = s
            };
            
            var writer = new System.IO.StringWriter();

            ExceptionAssert.Throws<Exception>(
                "An error occurred.",
                () => { serialiser.Serialize(writer, r); });
        }
            public IEnumerable<CompensationProvision> MatchingOffers(Somebody offeror,
                Something persistentObject,
                DateValidationType dateValidationType)
            {
                if (offeror == null || persistentObject == null)
                {
                    throw new ArgumentException("Missing offeror or object in price evaluation.");
                }

                List<CompensationProvision> validElements = new List<CompensationProvision>();
                IEnumerable<CompensationProvision> offerCandidates = GetOffers(persistentObject);

                foreach (CompensationProvision cod in offerCandidates)
                {
                    //Validate participating parts
                    if (!cod.AgreedCompensation.IsSomebodyAValidOfferor(offeror))
                    {
                        continue; //No match, check next offer.
                    }
                    if (CanAddElement(cod, dateValidationType))
                    {
                        validElements.Add(cod);
                    }
                }
                return validElements;
            }
示例#55
0
 public void SetTheLayout(Something theLayout)
 {
     SetWhatIs(theLayout);
 }
            /// <summary>
            /// 
            /// </summary>
            /// <param name="wantedType"></param>
            /// <param name="includedIn"></param>
            /// <param name="persistentObject"></param>
            /// <param name="amount"></param>
            /// <param name="quantity"></param>
            /// <param name="currencyKind"></param>
            /// <param name="validFrom"></param>
            /// <param name="validTo"></param>
            /// <returns></returns>
            public CompensationProvision NewCharge(
                CompensationProvision.Kind wantedType,
                AgreedCompensation includedIn,
                Something persistentObject,
                Decimal amount,
                Decimal quantity,
                Currency.Kind currencyKind,
                DateTime validFrom,
                DateTime validTo)
            {
                //Instantiate the new charge.
                CompensationProvision compensationProvision = NewCompensationProvision(wantedType, persistentObject, quantity, validFrom, validTo);

                //Initiate
                compensationProvision.CurrencyKind = currencyKind;
                compensationProvision.SetAppliesTo(persistentObject);
                compensationProvision.SetAgreedCompensation(includedIn);
                compensationProvision.Amount = amount;
                compensationProvision.IsRelative = false;
                return compensationProvision;
            }
 public void SetInformationAbout(Something informationAbout)
 {
     SetToWhat(informationAbout);
 }
 private void UpdateCombinedIndex(Something appliesTo, AgreedCompensation agreedCompensation)
 {
     int combinedIndex;
     CombinedIndexHelper.TryGet(appliesTo, agreedCompensation, true, out combinedIndex);/*Ok*/
     _combinedIndex = combinedIndex;
 }
示例#59
0
 public GenreHasWord(Word word, Something wordOwner, WordIndexAttribute.Kind attrKind)
     : base(word, wordOwner, attrKind)
 {
 }
 public void SetAppliesTo(Something something)
 {
     UpdateCombinedIndex(something, AgreedCompensation);
     _appliesTo = something;
 }