public void PersistData_LoadStream_CanReadSaveStream()
        {
            // Arrange
            string streamName = "EventStream1";

            var cashDeskStream = new CashDesk.Server.CashDeskEventStream()
            {
                StreamName = "EventStream1"
            };

            var dataEventsPersistence = new DataEventsPersistenceMock();

            cashDeskStream.AddTransaction(new Server.Entities.CashDeskTransaction(
                                              new DateTime(2021, 05, 05), "HAMMER", "Test", 20.12m, "1"));

            var dataPersistence = new PersistData <CashDesk.Server.CashDeskEventStream>(dataEventsPersistence);

            // Act
            dataPersistence.Save <DataCashDeskTransactionAddedEvent, CashDeskTransactionAddedEvent>(cashDeskStream);
            var result = dataPersistence.Load(streamName);

            // Assert
            Assert.Equal(streamName, result.StreamName);
            Assert.Equal(20.12m, result.CashDeskBalance["1"]);
        }
Esempio n. 2
0
        public void PersistData_Save()
        {
            // Arrange
            string streamName            = "EntityStream1";
            var    dataEventsPersistence = Substitute.For <DataPersistence.IDataEventsPersistence>();

            var cashDesk = new CashDesk.Server.CashDeskEventStream()
            {
                StreamName = streamName
            };
            var dataPersistence = new PersistData <CashDesk.Server.CashDeskEventStream>(dataEventsPersistence);

            cashDesk.AddTransaction(new Server.Entities.CashDeskTransaction(new DateTime(2021, 02, 05), "HAMMER", "Claw Hammer", 20.43m, "1"));
            cashDesk.AddTransaction(new Server.Entities.CashDeskTransaction(new DateTime(2021, 02, 05), "NAIL2_5", "2.5mm NAILS (100)", 0.94m, "1"));
            cashDesk.AddTransaction(new Server.Entities.CashDeskTransaction(new DateTime(2021, 02, 05), "NAIL1_8", "1.8mm NAILS (250)", 2.01m, "1"));

            // Act
            dataPersistence.Save <DataCashDeskTransactionAddedEvent, CashDeskTransactionAddedEvent>(cashDesk);

            // Assert
            dataEventsPersistence.Received(1).Append(Arg.Is <string>(streamName), Arg.Any <string>());
        }
        static void Main(string[] args)
        {
            _cashDeskEventStream = _persistData.Load("Stream1");

            while (true)
            {
                Console.WriteLine("1 - Add till transaction");
                Console.WriteLine("2 - View till balance");
                Console.WriteLine("3 - View all till balances");
                Console.WriteLine("4 - View all transactions");
                Console.WriteLine("5 - Exit");

                var key = Console.ReadKey();

                switch (key.Key)
                {
                case ConsoleKey.D1:
                    AddTransactionDialog();
                    break;

                case ConsoleKey.D2:
                    GetBalanceForTillDialog();
                    break;

                case ConsoleKey.D3:
                    GetBalanceForAllTillsDialog();
                    break;

                case ConsoleKey.D4:
                    GetTransactionHistory();
                    break;

                default:
                    _persistData.Save <DataCashDeskTransactionAddedEvent, CashDeskTransactionAddedEvent>(_cashDeskEventStream);
                    return;
                }
            }
        }
Esempio n. 4
0
 void OnDisable()
 {
     instance.Save();
 }