public void SaveEventsTest()
        {
            var aggregateRootId = Guid.NewGuid();
            var employee        = new Employee {
                Id = aggregateRootId
            };

            var event1 = new NameChangedEvent("daxnet");
            var event2 = new TitleChangedEvent("title");
            var event3 = new RegisteredEvent();

            event1.AttachTo(employee);
            event2.AttachTo(employee);
            event3.AttachTo(employee);

            var storeConfig       = new AdoNetEventStoreConfiguration(PostgreSQLFixture.ConnectionString, new GuidKeyGenerator());
            var payloadSerializer = new ObjectJsonSerializer();
            var store             = new PostgreSqlEventStore(storeConfig, payloadSerializer);

            store.Save(new List <DomainEvent>
            {
                event1,
                event2,
                event3
            });
        }
        public void SaveEventsTest1()
        {
            var aggregateRootId = Guid.NewGuid();
            var employee        = new Employee(aggregateRootId);

            var event1 = new NameChangedEvent("daxnet");
            var event2 = new TitleChangedEvent("title");
            var event3 = new RegisteredEvent();

            event1.AttachTo(employee);
            event2.AttachTo(employee);
            event3.AttachTo(employee);

            var store = new DictionaryEventStore();

            store.Save(new List <DomainEvent>
            {
                event1,
                event2,
                event3
            });

            var events = store.Load <Guid>(typeof(Employee).AssemblyQualifiedName, aggregateRootId);

            Assert.Equal(3, events.Count());
            Assert.NotEqual(Guid.Empty, event1.Id);
            Assert.NotEqual(Guid.Empty, event2.Id);
            Assert.NotEqual(Guid.Empty, event3.Id);
        }
        public void LoadEventsTest()
        {
            var aggregateRootId = Guid.NewGuid();
            var employee        = new Employee(aggregateRootId);

            var event1 = new NameChangedEvent("daxnet");
            var event2 = new TitleChangedEvent("title");
            var event3 = new RegisteredEvent();

            event1.AttachTo(employee);
            event2.AttachTo(employee);
            event3.AttachTo(employee);

            var storeConfig       = new AdoNetEventStoreConfiguration(PostgreSQLFixture.ConnectionString, new GuidKeyGenerator());
            var payloadSerializer = new ObjectJsonSerializer();
            var store             = new PostgreSqlEventStore(storeConfig, payloadSerializer);

            store.Save(new List <DomainEvent>
            {
                event1,
                event2,
                event3
            });

            var events = store.Load <Guid>(typeof(Employee).AssemblyQualifiedName, aggregateRootId);

            Assert.Equal(3, events.Count());
        }
        private void UpdateTitle()
        {
            string title = "";

            if (string.IsNullOrEmpty(_file.Path))
            {
                title += "New File";
            }
            else
            {
                title += _file.Name;
            }

            if (_file.UnsavedChanges)
            {
                title += '*';
            }

            TitleChangedEvent?.Invoke(title);
        }
        public void LoadEventsWithMinMaxSequenceTest()
        {
            var aggregateRootId = Guid.NewGuid();
            var employee        = new Employee(aggregateRootId);

            var event1 = new NameChangedEvent("daxnet")
            {
                Sequence = 1
            };
            var event2 = new TitleChangedEvent("title")
            {
                Sequence = 2
            };
            var event3 = new RegisteredEvent()
            {
                Sequence = 3
            };

            event1.AttachTo(employee);
            event2.AttachTo(employee);
            event3.AttachTo(employee);

            var storeConfig       = new AdoNetEventStoreConfiguration(SQLServerFixture.ConnectionString, new GuidKeyGenerator());
            var payloadSerializer = new ObjectJsonSerializer();
            var store             = new SqlServerEventStore(storeConfig, payloadSerializer);

            store.Save(new List <DomainEvent>
            {
                event1,
                event2,
                event3
            });

            var events = store.Load <Guid>(typeof(Employee).AssemblyQualifiedName, aggregateRootId, 1, 3).ToList();

            Assert.Equal(3, events.Count);
            Assert.IsType <NameChangedEvent>(events[0]);
            Assert.IsType <TitleChangedEvent>(events[1]);
            Assert.IsType <RegisteredEvent>(events[2]);
        }
Exemple #6
0
 private void HandlesTitleChangedEvent(TitleChangedEvent evnt)
 {
     this.Title = $"Sr. {evnt.Title}";
 }
Exemple #7
0
        public Exception Open(string path)
        {
            file.Path = path;
            TitleChangedEvent?.Invoke(file.Name);

            TargaFile targaFile = TargaFile.Read(path);

            int width  = targaFile.Header.Width;
            int height = targaFile.Header.Height;

            WriteableBitmap bitmap = new WriteableBitmap(width, height, 90, 90, PixelFormats.Bgra32, null);

            byte[] buffer = new byte[width * height * 4];

            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    int   pos     = (x + y * width) * 4;
                    var   lookupX = width - x - 1;
                    Color color   = targaFile.Pixels[lookupX, y];
                    buffer[pos]     = color.B;
                    buffer[pos + 1] = color.G;
                    buffer[pos + 2] = color.R;
                    buffer[pos + 3] = color.A;
                }
            }

            Int32Rect rect = new Int32Rect(0, 0, width, height);

            bitmap.WritePixels(rect, buffer, width * 4, 0);

            OutputImage.Source = bitmap;
            FileInfo fileInfo = new FileInfo(file.Path);

            InspectorContent = new InspectorContent(
                file.Name,
                new InspectorTableEntry[]
            {
                new InspectorTableEntry("Path", file.Path, file.Path),
                new InspectorTableEntry("File Size", FileSizeFormatter.FormatSize(fileInfo.Length)),
                new InspectorTableEntry("Creation time", fileInfo.CreationTime.ToString(CultureInfo.InvariantCulture)),
                new InspectorTableEntry("Last change", fileInfo.LastWriteTime.ToString(CultureInfo.InvariantCulture)),
                new InspectorTableEntry("Dimensions", width + " x " + height, $"Height:\t{height}\nWidth:\t{width}"),
                new InspectorTableEntry("Dimensions1", width + " x " + height, $"Height:\t{height}\nWidth:\t{width}"),
                new InspectorTableEntry("Dimensions2", width + " x " + height, $"Height:\t{height}\nWidth:\t{width}"),
                new InspectorTableEntry("Dimensions3", width + " x " + height, $"Height:\t{height}\nWidth:\t{width}"),
                new InspectorTableEntry("Dimensions4", width + " x " + height, $"Height:\t{height}\nWidth:\t{width}"),
                new InspectorTableEntry("Dimensions5", width + " x " + height, $"Height:\t{height}\nWidth:\t{width}"),
                new InspectorTableEntry("Dimensions6", width + " x " + height, $"Height:\t{height}\nWidth:\t{width}"),
                new InspectorTableEntry("Dimensions7", width + " x " + height, $"Height:\t{height}\nWidth:\t{width}"),
                new InspectorTableEntry("Dimensions8", width + " x " + height, $"Height:\t{height}\nWidth:\t{width}"),
                new InspectorTableEntry("Dimensions9", width + " x " + height, $"Height:\t{height}\nWidth:\t{width}"),
                new InspectorTableEntry("Dimensions11", width + " x " + height, $"Height:\t{height}\nWidth:\t{width}"),
                new InspectorTableEntry("Dimensions12", width + " x " + height, $"Height:\t{height}\nWidth:\t{width}"),
                new InspectorTableEntry("Dimensions13", width + " x " + height, $"Height:\t{height}\nWidth:\t{width}"),
                new InspectorTableEntry("Dimensions14", width + " x " + height, $"Height:\t{height}\nWidth:\t{width}"),
                new InspectorTableEntry("Dimensions15", width + " x " + height, $"Height:\t{height}\nWidth:\t{width}"),
                new InspectorTableEntry("Dimensions16", width + " x " + height, $"Height:\t{height}\nWidth:\t{width}"),
                new InspectorTableEntry("Dimensions17", width + " x " + height, $"Height:\t{height}\nWidth:\t{width}"),
                new InspectorTableEntry("Dimensions18", width + " x " + height, $"Height:\t{height}\nWidth:\t{width}"),
                new InspectorTableEntry("Dimensions19", width + " x " + height, $"Height:\t{height}\nWidth:\t{width}"),
                new InspectorTableEntry("Dimensions21", width + " x " + height, $"Height:\t{height}\nWidth:\t{width}"),
                new InspectorTableEntry("Dimensions22", width + " x " + height, $"Height:\t{height}\nWidth:\t{width}"),
                new InspectorTableEntry("Dimensions23", width + " x " + height, $"Height:\t{height}\nWidth:\t{width}"),
                new InspectorTableEntry("Dimensions24", width + " x " + height, $"Height:\t{height}\nWidth:\t{width}"),
            },
                new Image()
            {
                Source = new DrawingImage()
                {
                    Drawing = (Drawing)FindResource("Image")
                }
            });

            return(null);
        }