コード例 #1
0
ファイル: HistoryTests.cs プロジェクト: noahfalk/roslyn
        public void TestMaxLength()
        {
            var buffer = _testHost.ExportProvider.GetExport<ITextBufferFactoryService>().Value.CreateTextBuffer();
            buffer.Insert(0, "0123456789");
            var snapshot = buffer.CurrentSnapshot;

            var history = new History(maxLength: 0);

            history.Add(new SnapshotSpan(snapshot, new Span(0, 1)));
            Assert.Empty(GetHistoryEntries(history));

            history = new History(maxLength: 1);
            history.Add(new SnapshotSpan(snapshot, new Span(0, 1)));
            Assert.Equal(new[] { "0" }, GetHistoryEntries(history));
            history.Add(new SnapshotSpan(snapshot, new Span(1, 1)));
            Assert.Equal(new[] { "1" }, GetHistoryEntries(history)); // Oldest entry is dropped.

            history = new History(maxLength: 2);
            history.Add(new SnapshotSpan(snapshot, new Span(0, 1)));
            Assert.Equal(new[] { "0" }, GetHistoryEntries(history));
            history.Add(new SnapshotSpan(snapshot, new Span(1, 1)));
            Assert.Equal(new[] { "0", "1" }, GetHistoryEntries(history));
            history.Add(new SnapshotSpan(snapshot, new Span(2, 1)));
            Assert.Equal(new[] { "1", "2" }, GetHistoryEntries(history)); // Oldest entry is dropped.
        }
コード例 #2
0
ファイル: TestHistory.cs プロジェクト: bvssvni/csharp-play
        public void TestAfter()
        {
            var a = new History ();
            a.Add (new DateTime (2003, 3, 15));
            a.Add (new DateTime (2003, 3, 20));

            var b = a.After (new DateTime (2003, 3, 18));
            Assert.True (b.Count == 2);
            Assert.True (b[0] == new DateTime (2003, 3, 18));
            Assert.True (b[1] == new DateTime (2003, 3, 20));
        }
コード例 #3
0
        public void dont_raise_trainerDisabled_if_already_disabled()
        {
            var history = new History();

            history.Add(new TrainerCreated(Guid.NewGuid(), 1, "BOUDOUX", "Aurelien", "*****@*****.**"));
            history.Add(new TrainerDisabled(Guid.NewGuid(), 2));
            var trainer = new Trainer(history);

            trainer.Disable();

            trainer.UncommitedEvents.GetStream().Should().BeEmpty();
        }
コード例 #4
0
        public void throw_error_if_trying_to_delete_assigned_trainer()
        {
            var history = new History();

            history.Add(new TrainerCreated(Guid.NewGuid(), 1, "BOUDOUX", "Aurelien", "*****@*****.**"));
            history.Add(new TrainerAssigned(Guid.NewGuid(), 2, new DateTime(2017, 01, 15), 10));
            var trainer = new Trainer(history);

            Action action = () => trainer.Delete();

            action.ShouldThrow <ForbiddenDeleteTrainerException>();
        }
コード例 #5
0
        public void raise_trainerUnassigned_if_trainer_no_longer_assigned_to_a_session()
        {
            var history = new History();

            history.Add(new TrainerCreated(Guid.NewGuid(), 1, "BOUDOUX", "Aurelien", "*****@*****.**"));
            history.Add(new TrainerAssigned(Guid.NewGuid(), 2, new DateTime(2017, 01, 15), 10));
            history.Add(new TrainerAssigned(Guid.NewGuid(), 2, new DateTime(2017, 02, 15), 10));
            var trainer = new Trainer(history);

            trainer.UnAssign(new DateTime(2017, 02, 15), 10);
            trainer.UncommitedEvents.GetStream().Should().Contain(new TrainerUnassigned(Guid.Empty, 0, new DateTime(2017, 02, 15), 10));
        }
コード例 #6
0
        public void raise_assignationChanged_when_change_trainer_assignation()
        {
            var history = new History();

            history.Add(new TrainerCreated(Guid.NewGuid(), 1, "BOUDOUX", "Aurelien", "*****@*****.**"));
            history.Add(new TrainerAssigned(Guid.NewGuid(), 2, new DateTime(2017, 01, 15), 10));
            var trainer = new Trainer(history);

            trainer.ChangeAssignation(new DateTime(2017, 01, 15), 10, new DateTime(2017, 01, 10), 10);

            trainer.UncommitedEvents.GetStream().Should().Contain(new TrainerReassigned(Guid.Empty, 0, new DateTime(2017, 01, 15), 10, new DateTime(2017, 01, 10), 10));
        }
コード例 #7
0
        public void raise_locationUnassigned_if_lieu_no_longer_assigned_to_a_session()
        {
            var history = new History();

            history.Add(new LocationCreated(Guid.NewGuid(), 1, "Lyon", "test", 5));
            history.Add(new LocationAssigned(Guid.NewGuid(), 2, new DateTime(2017, 01, 15), 10));
            history.Add(new LocationAssigned(Guid.NewGuid(), 3, new DateTime(2017, 02, 15), 10));
            var location = new Location(history);

            location.UnAssign(new DateTime(2017, 02, 15), 10);
            location.UncommitedEvents.GetStream().Should().Contain(new LocationUnassigned(Guid.Empty, 0, new DateTime(2017, 02, 15), 10));
        }
コード例 #8
0
        public void TestMain()
        {
            var hist = new History<string>(maxCount: 2);

            hist.Add("one");
            hist.Add("two");
            hist.Add("three");

            Assert.IsTrue(hist.Count == 2);
            Assert.IsTrue(hist[0] == "three");
            Assert.IsTrue(hist[1] == "two");
        }
コード例 #9
0
        public void dont_raise_multiple_update_if_last_update_is_same_data()
        {
            var history = new History();

            history.Add(new LocationCreated(Guid.Empty, 1, "Saint Priest", "yolo", 1));
            history.Add(new LocationUpdated(Guid.Empty, 2, "Saint Priest", "test", 1));

            var location = new Location(history);

            location.Update("Saint Priest", "test", 1);
            location.UncommitedEvents.GetStream().Should().BeEmpty();
        }
コード例 #10
0
        public void dont_raise_stagiaireDeleted_if_stagiaire_already_deleted()
        {
            var history = new History();

            history.Add(new StudentCreated(Guid.NewGuid(), 1, "BOUDOUX", "Aurélien"));
            history.Add(new StudentDeleted(Guid.Empty, 1));

            var student = new Student(history);

            student.Delete();
            student.UncommitedEvents.GetStream().Should().BeEmpty();
        }
コード例 #11
0
        public void throw_error_if_trying_to_delete_assigned_location()
        {
            var history = new History();

            history.Add(new LocationCreated(Guid.NewGuid(), 1, "Paris", "test", 5));
            history.Add(new LocationAssigned(Guid.NewGuid(), 2, new DateTime(2017, 01, 15), 10));
            var location = new Location(history);

            Action action = () => location.Delete();

            action.ShouldThrow <ForbiddenDeleteLocationException>();
        }
コード例 #12
0
        public void dont_raise_LocationDeleted_if_location_already_deleted()
        {
            var history = new History();

            history.Add(new LocationCreated(Guid.Empty, 1, "Saint Priest", "yolo", 1));
            history.Add(new LocationDeleted(Guid.Empty, 2));

            var location = new Location(history);

            location.Delete();
            location.UncommitedEvents.GetStream().Should().BeEmpty();
        }
コード例 #13
0
ファイル: TestHistory.cs プロジェクト: bvssvni/csharp-play
        public void TestBefore()
        {
            var a = new History ();
            a.Add (new DateTime (2002, 3, 15));
            a.Add (new DateTime (2002, 3, 20));

            var b = a.Before (new DateTime (2002, 3, 18));
            Assert.False (b.Inverted);
            Assert.True (b.Count == 2);
            Assert.True (b[0] == new DateTime (2002, 3, 15));
            Assert.True (b[1] == new DateTime (2002, 3, 18));
        }
コード例 #14
0
        public void raise_locationReasigned_when_change_location_assignation()
        {
            var history = new History();

            history.Add(new LocationCreated(Guid.NewGuid(), 1, "Lyon", "test", 5));
            history.Add(new LocationAssigned(Guid.NewGuid(), 2, new DateTime(2017, 01, 15), 10));
            var location = new Location(history);

            location.ChangeAssignation(new DateTime(2017, 01, 15), 10, new DateTime(2017, 01, 10), 10);

            location.UncommitedEvents.GetStream().Should().Contain(new LocationReassigned(Guid.Empty, 0, new DateTime(2017, 01, 15), 10, new DateTime(2017, 01, 10), 10));
        }
コード例 #15
0
        public void throw_error_if_trying_to_reassign_trainer_to_an_already_assigned_session()
        {
            var history = new History();

            history.Add(new TrainerCreated(Guid.NewGuid(), 1, "BOUDOUX", "Aurelien", "*****@*****.**"));
            history.Add(new TrainerAssigned(Guid.NewGuid(), 2, new DateTime(2017, 01, 15), 10));
            history.Add(new TrainerAssigned(Guid.NewGuid(), 2, new DateTime(2017, 02, 15), 10));
            var trainer = new Trainer(history);

            Action action = () => trainer.ChangeAssignation(new DateTime(2017, 01, 15), 10, new DateTime(2017, 02, 10), 10);

            action.ShouldThrow <TrainerAlreadyAssignedException>();
        }
コード例 #16
0
        public void throw_error_if_formateur_already_assigned_to_a_session(string startDate, int duration)
        {
            var history = new History();

            history.Add(new TrainerCreated(Guid.NewGuid(), 1, "BOUDOUX", "Aurelien", "*****@*****.**"));
            history.Add(new TrainerAssigned(Guid.NewGuid(), 2, new DateTime(2017, 01, 15), 10));
            var trainer = new Trainer(history);

            var    start  = DateTime.ParseExact(startDate, "dd/MM/yyyy", new DateTimeFormatInfo());
            Action action = () => trainer.Assign(start, duration);

            action.ShouldThrow <TrainerAlreadyAssignedException>();
        }
コード例 #17
0
        public void throw_error_if_trying_to_reassign_location_to_an_already_assigned_session()
        {
            var history = new History();

            history.Add(new LocationCreated(Guid.NewGuid(), 1, "Lyon", "test", 5));
            history.Add(new LocationAssigned(Guid.NewGuid(), 2, new DateTime(2017, 01, 15), 10));
            history.Add(new LocationAssigned(Guid.NewGuid(), 3, new DateTime(2017, 02, 15), 10));
            var location = new Location(history);

            Action action = () => location.ChangeAssignation(new DateTime(2017, 01, 15), 10, new DateTime(2017, 02, 10), 10);

            action.ShouldThrow <LocationAlreadyAssignedException>();
        }
コード例 #18
0
        public void throw_error_if_location_already_assigned_to_a_session(string startDate, int duration)
        {
            var history = new History();

            history.Add(new LocationCreated(Guid.NewGuid(), 1, "Lyon", "test", 5));
            history.Add(new LocationAssigned(Guid.NewGuid(), 2, new DateTime(2017, 01, 15), 10));
            var location = new Location(history);

            var    start  = DateTime.ParseExact(startDate, "dd/MM/yyyy", new DateTimeFormatInfo());
            Action action = () => location.Assign(start, duration);

            action.ShouldThrow <LocationAlreadyAssignedException>();
        }
コード例 #19
0
        public void dont_raise_update_if_last_update_equal()
        {
            var history    = new History();
            var trainingId = Guid.NewGuid();

            history.Add(new TrainingCreated(trainingId, 1, "TED", 1, Color.Empty.ToArgb()));
            history.Add(new TrainingUpdated(trainingId, 2, "WELL", 1, Color.Empty.ToArgb()));

            var training = new Training(history);

            training.Update("WELL", 1, Color.Empty.ToArgb());

            training.UncommitedEvents.GetStream().Should().BeEmpty();
        }
コード例 #20
0
        public void dont_raise_trainingDeleted_if_training_already_deleted()
        {
            var history    = new History();
            var trainingId = Guid.NewGuid();

            history.Add(new TrainingCreated(trainingId, 1, "TED", 1, Color.Empty.ToArgb()));
            history.Add(new TrainingDeleted(trainingId, 2));

            var training = new Training(history);

            training.Delete();

            training.UncommitedEvents.GetStream().Should().BeEmpty();
        }
コード例 #21
0
        public void reasign_old_period_if_properly_removed_from_event_store()
        {
            var history = new History();

            history.Add(new TrainerCreated(Guid.NewGuid(), 1, "BOUDOUX", "Aurelien", "*****@*****.**"));
            history.Add(new TrainerAssigned(Guid.NewGuid(), 2, new DateTime(2017, 01, 15), 10));
            history.Add(new TrainerUnassigned(Guid.NewGuid(), 2, new DateTime(2017, 01, 15), 10));

            var trainer = new Trainer(history);

            trainer.Assign(new DateTime(2017, 01, 13), 10);

            trainer.UncommitedEvents.GetStream().Should().Contain(new TrainerAssigned(Guid.Empty, 1, new DateTime(2017, 01, 13), 10));
        }
コード例 #22
0
        public void reasign_old_period_if_properly_removed_from_event_store()
        {
            var history = new History();

            history.Add(new LocationCreated(Guid.NewGuid(), 1, "Paris", "test", 5));
            history.Add(new LocationAssigned(Guid.NewGuid(), 2, new DateTime(2017, 01, 15), 10));
            history.Add(new LocationUnassigned(Guid.NewGuid(), 2, new DateTime(2017, 01, 15), 10));

            var location = new Location(history);

            location.Assign(new DateTime(2017, 01, 13), 10);

            location.UncommitedEvents.GetStream().Should().Contain(new LocationAssigned(Guid.Empty, 1, new DateTime(2017, 01, 13), 10));
        }
コード例 #23
0
ファイル: TestHistory.cs プロジェクト: bvssvni/csharp-play
        public void TestIntersect()
        {
            var a = new History ();
            a.Add (new DateTime (2005, 1, 1));
            a.Add (new DateTime (2005, 1, 6));

            var b = new History ();
            b.Add (new DateTime (2005, 1, 5));
            b.Add (new DateTime (2005, 1, 10));

            var c = a * b;
            Assert.True (c.Count == 2);
            Assert.True (c[0] == new DateTime (2005, 1, 5));
            Assert.True (c[1] == new DateTime (2005, 1, 6));
        }
コード例 #24
0
        private void InitializeServer()
        {
            StopMessageServer();

            // TODO: add message port to config file
            try
            {
                _server = new Server <string>(cbLocalIp.SelectedItem as IPAddress, 15000, _client);
            }
            catch (Exception exc)
            {
                MessageBox.Show("Невозможно установить соединение: неверный IP и/или занят порт\n" + exc.Message);
            }

            if (_server != null)
            {
                _server.ObjectsChanged += (s, e) =>
                {
                    Dispatcher.BeginInvoke((Action)(() =>
                    {
                        History.Add(_server.Objects.Last());
                    }));
                };
            }
        }
コード例 #25
0
        public void StartGame()
        {
            foreach (var camel in GameState.Camels)
            {
                History.Add(new StartPositionStateChange(camel));
            }

            var gameStateClone = GameState.Clone(-1);
            var playerNames    = Players.Select(x => x.Name).ToArray();

            var gameInfo = new GameInfo()
            {
                GameId  = GameId,
                Players = playerNames
            };

            for (var i = 0; i < Players.Count; i++)
            {
                var player = Players[i];
                player.Reset(i);
                History.Add(new StateChange(StateAction.GetMoney, player.PlayerId, CamelColor.Blue, 3));

                Attempt(() => {
                    player.PerformAction(x => x.StartNewGame(i, gameInfo, gameStateClone));
                });

                if (player.PlayerInterface is ISeeded)
                {
                    Attempt(() => {
                        player.PerformAction(x => ((ISeeded)x).SetRandomSeed(Rnd.Next()));
                    });
                }
            }
        }
コード例 #26
0
        public void Start(TrainingOptions options)
        {
            if (state == SessionState.Stopped)
            {
                History.Add("Training Starting", status, options);

                string[] inputColumns  = AdaptiveSystem.Interface.GetNames(InputOutput.Input);
                string[] outputColumns = AdaptiveSystem.Interface.GetNames(InputOutput.Output);

                object dataInput  = DataSource.GetData(inputColumns, DataSourceSet.Training);
                object dataOutput = DataSource.GetData(outputColumns, DataSourceSet.Training);

                AdaptiveSystem.Preprocess.Apply(dataInput);
                AdaptiveSystem.Postprocess.Reverse(dataOutput);

                TrainingThreadParameters parameters = new TrainingThreadParameters();
                parameters.Options = this.Options.Copy();
                //parameters.Inputs = convert(dataInput);
                //parameters.Outputs = convert(dataOutput);


                backgroundWorker.RunWorkerAsync(parameters);
            }
            else if (state == SessionState.Paused)
            {
                History.Add("Training Resumed", status);
                state = SessionState.Running;
            }
        }
コード例 #27
0
        private void DeserializeSchemsHistory()
        {
            using (var streamReader = new StreamReader(Path.Combine(HistoryDataPath, HistoryCacheFile)))
            {
                var xmlSerializer = new XmlSerializer(typeof(Histories));
                var histories     = xmlSerializer.Deserialize(streamReader) as Histories;

                if (histories == null)
                {
                    throw new InvalidOperationException("The History Chace File Is Corrupted. It was deleted!");
                }

                Schemes.Clear();
                History.Clear();
                foreach (var history in histories.AllHistories)
                {
                    var scheme = SchemeCache.ByTitle(history.Scheme.Title);

                    // Is this update necessary? Maybe the scheme was changed and so the history gets updated?
                    history.Scheme = scheme;

                    Schemes.Add(history.Scheme, history);
                    History.Add(history);
                }
            }
        }
コード例 #28
0
    void EvalInputString(string inputString)
    {
        inputString = inputString.Trim();

        if (string.IsNullOrEmpty(inputString))
        {
            LogMessage(Message.Input(string.Empty));
            return;
        }

        _history.Add(inputString);
        LogMessage(Message.Input(inputString));

        var input = new List <string>(inputString.Split(new char[] { ' ' }, System.StringSplitOptions.RemoveEmptyEntries));

        input = input.ConvertAll <string>(low => {
            return(low.ToLower());
        });
        var cmd = input[0];

        if (_cmdTable.ContainsKey(cmd))
        {
            Log(_cmdTable[cmd](input.ToArray()), MessageType.OUTPUT);
        }
        else
        {
            LogMessage(Message.Output(string.Format("*** Unknown Command: {0} ***", cmd)));
        }
    }
コード例 #29
0
        /// <summary>
        /// Adds a write to the History, deleting any other writes or portions of writes within its range.
        /// </summary>
        public void Add(Write write)
        {
            Program.Core.FEH.Changed = true;

            Delete(write.Address, write.Address + write.Data.Length);
            History.Add(write);
        }
コード例 #30
0
 public void AddHistory(string message)
 {
     History.Add(
         new TableHistory(
             message,
             DateTime.Now));
 }
コード例 #31
0
 public Executable()
 {
     History.Add("");
     StartupTimer.Tick          += StartupTimer_Tick;
     PropertyChanged            += Executable_PropertyChanged;
     Commands.CollectionChanged += Commands_CollectionChanged;
 }
コード例 #32
0
 public SxcMvc(IHttpContextAccessor httpContextAccessor, MvcPageProperties pageProperties) : base("Mvc.View")
 {
     PageProperties = pageProperties;
     _httpContext   = httpContextAccessor.HttpContext;
     // add log to history!
     History.Add("sxc-mvc-view", Log);
 }
コード例 #33
0
        public void Dispatch <T>(T action) where T : TAction
        {
            lock (_syncRoot)
            {
                var mutationQuery = action is IStaticMutation ? ((IStaticMutation)action).Mutation : QueryHelpers.AddQueryString(action.GetType().Name.ToUpperInvariant(), action.ToDictionary());

                if (action is InitialAction)
                {
                    History.Add(new HistoricEntry <TState, TAction>(new ActionState <TState, TAction>()
                    {
                        State = State, Action = action
                    }));
                    Dispatcher.OnNext(action);
                }
                else
                {
                    TState newState = new TState();
                    Mapper.Map <TState, TState>(LastState, newState);
                    State = newState;
                    History.Add(new HistoricEntry <TState, TAction>(new ActionState <TState, TAction>()
                    {
                        State = newState, Action = action
                    }));
                    Dispatcher.OnNext(action);
                }
            }
        }
コード例 #34
0
ファイル: User.cs プロジェクト: GGSimmons1992/gary-ms
 public void AddOrder(Order newOrder)
 {
     if (newOrder.Voidable == false)
     {
         History.Add(newOrder);
     }
 }
コード例 #35
0
        public static void MoveGraph(object s, RoutedEventArgs e)
        {
            if (Globals.AnimationsNow.Count != 0)
            {
                return;
            }
            try
            {
                double topBorder    = Globals.VertexData[0].Coordinates.Y;
                double bottomBorder = Globals.VertexData[0].Coordinates.Y;
                double leftBorder   = Globals.VertexData[0].Coordinates.X;
                double rightBorder  = Globals.VertexData[0].Coordinates.X;

                foreach (var vertex in Globals.VertexData)
                {
                    if (vertex.Coordinates.Y > bottomBorder)
                    {
                        bottomBorder = vertex.Coordinates.Y;
                    }
                    if (vertex.Coordinates.Y < topBorder)
                    {
                        topBorder = vertex.Coordinates.Y;
                    }
                    if (vertex.Coordinates.X > rightBorder)
                    {
                        rightBorder = vertex.Coordinates.X;
                    }
                    if (vertex.Coordinates.X < leftBorder)
                    {
                        leftBorder = vertex.Coordinates.X;
                    }
                }

                double centerX = ((rightBorder - leftBorder) / 2) + leftBorder;
                double centerY = ((bottomBorder - topBorder) / 2) + topBorder;

                Point centerGraph  = new Point(centerX, centerY);
                Point centerCanvas = new Point(MainWindow.Instance.GraphCanvas.ActualWidth / 2, MainWindow.Instance.GraphCanvas.ActualHeight / 2);

                Vector vector = Point.Subtract(centerCanvas, centerGraph);

                foreach (var vertex in Globals.VertexData)
                {
                    vertex.Coordinates = Point.Add(vertex.Coordinates, vector);
                }

                List <Point> startPoints = new List <Point>();
                startPoints.Add(centerGraph);

                List <Point> finishPoints = new List <Point>();
                finishPoints.Add(centerCanvas);

                History.Add(startPoints, finishPoints);

                MainWindow.Instance.Invalidate();
            }
            catch
            {
            }
        }
コード例 #36
0
ファイル: TestHistory.cs プロジェクト: bvssvni/csharp-play
        public void TestInvertedIntersect()
        {
            var a = History.AllTime ();
            a.Add (new DateTime (2010, 1, 1));
            a.Add (new DateTime (2010, 1, 10));

            var b = new History ();
            b.Add (new DateTime (2010, 1, 8));
            b.Add (new DateTime (2010, 1, 12));

            var c = History.Intersect (a, b);
            Assert.False (c.Inverted);
            Assert.True (c[0] == new DateTime (2010, 1, 10));
            Assert.True (c[1] == new DateTime (2010, 1, 12));

            var d = History.Intersect (b, a);
            Assert.False (d.Inverted);
            Assert.True (d[0] == new DateTime (2010, 1, 10));
            Assert.True (d[1] == new DateTime (2010, 1, 12));

            b.Inverted = true;
            var e = History.Intersect (a, b);
            Assert.True (e.Inverted);
            Assert.True (e[0] == new DateTime (2010, 1, 1));
            Assert.True (e[1] == new DateTime (2010, 1, 12));
        }
コード例 #37
0
ファイル: TestHistory.cs プロジェクト: bvssvni/csharp-play
        public void TestNormalInfiniteUnion2()
        {
            var a = new History ();
            a.Add (new DateTime (2009, 1, 1));

            var b = new History ();
            b.Add (new DateTime (2009, 1, 2));

            var c = a + b;
            Assert.True (c.Count == 1);
            Assert.True (c[0] == new DateTime (2009, 1, 1));

            var d = b + a;
            Assert.True (d.Count == 1);
            Assert.True (d[0] == new DateTime (2009, 1, 1));
        }
コード例 #38
0
ファイル: TestHistory.cs プロジェクト: bvssvni/csharp-play
 public void TestIsEmpty()
 {
     var a = new History ();
     Assert.True (History.IsEmpty (a));
     Assert.True (History.IsEmpty (null));
     a.Add (new DateTime (2004, 1, 1));
     Assert.False (History.IsEmpty (a));
 }
コード例 #39
0
ファイル: TestHistory.cs プロジェクト: bvssvni/csharp-play
 public void TestIsFinite()
 {
     var history = new History ();
     history.Add (new DateTime (2002, 1, 1));
     Assert.False (History.IsFinite (history));
     history.Add (new DateTime (2002, 1, 4));
     Assert.True (History.IsFinite (history));
 }
コード例 #40
0
ファイル: TestHistory.cs プロジェクト: bvssvni/csharp-play
        public void TestIsSequential()
        {
            var a = new History ();
            a.Add (new DateTime (2003, 1, 1));
            a.Add (new DateTime (2002, 12, 18));
            Assert.False (a.IsSequential ());

            var b = new History ();
            b.Add (new DateTime (2002, 12, 18));
            b.Add (new DateTime (2003, 1, 1));
            Assert.True (b.IsSequential ());
        }
コード例 #41
0
ファイル: TestHistory.cs プロジェクト: bvssvni/csharp-play
        public void TestNormalInfiniteIntersect()
        {
            var a = new History ();
            a.Add (new DateTime (2009, 1, 1));

            var b = new History ();
            b.Add (new DateTime (2010, 1, 1));
            b.Add (new DateTime (2010, 1, 10));

            var c = a * b;
            Assert.False (c.Inverted);
            Assert.True (c.Count == 2);
            Assert.True (c[0] == new DateTime (2010, 1, 1));
            Assert.True (c[1] == new DateTime (2010, 1, 10));
        }
コード例 #42
0
ファイル: TestHistory.cs プロジェクト: bvssvni/csharp-play
        public void TestNormalInfiniteIntersect2()
        {
            var a = new History ();
            a.Add (new DateTime (2002, 1, 1));

            var b = new History ();
            b.Add (new DateTime (2002, 1, 10));

            var c = a * b;
            Assert.True (c.Count == 1);
            Assert.True (c[0] == new DateTime (2002, 1, 10));

            var d = b * a;
            Assert.True (d.Count == 1);
            Assert.True (d[0] == new DateTime (2002, 1, 10));
        }
コード例 #43
0
ファイル: TestHistory.cs プロジェクト: bvssvni/csharp-play
        public void TestNormalInfiniteSubtract2()
        {
            var a = new History ();
            a.Add (new DateTime (2003, 1, 1));

            var b = new History ();
            b.Add (new DateTime (2003, 1, 5));

            var c = a - b;
            Assert.True (c.Count == 2);
            Assert.True (c[0] == new DateTime (2003, 1, 1));
            Assert.True (c[1] == new DateTime (2003, 1, 5));

            var d = b - a;
            Assert.True (d.Count == 0);
        }
コード例 #44
0
ファイル: TestHistory.cs プロジェクト: bvssvni/csharp-play
 public void TestSum()
 {
     var a = new History ();
     a.Add (new DateTime (2008, 3, 1));
     a.Add (new DateTime (2008, 3, 8));
     var sum = History.Sum (a);
     Assert.True (sum.TotalDays == 7);
 }