Example #1
0
        public void TestListTransactionsByInstrumentId()
        {
            var hundredRuppees = new Price(100);
            var relianceMutuals = new Symbol("RELTICK");
            Instrument instrument = new MutualFund(relianceMutuals, hundredRuppees, "Test Fund", "SUNMF", "SUN Magma", "Growth");
            repository.Save(instrument);

            Transaction buyTransaction = new BuyTransaction(DateTime.Now, instrument, 10, new Price(1000), 100, 100);
            repository.Save(buyTransaction);

            IList<Transaction> translist=repository.ListTransactionsByInstrumentId<Transaction>(instrument.Id);

            Assert.AreEqual(1,repository.ListTransactionsByInstrumentId<Transaction>(instrument.Id).Count);
        }
Example #2
0
        public void TestListAllSymbols()
        {
            var hundredRuppees = new Price(100);
            var relianceMutuals = new Symbol("RELTICK");

            Instrument instrument = new MutualFund(relianceMutuals, hundredRuppees, "Test Fund", "SUNMF", "SUN Magma", "Growth");

            repository.Save(instrument);

            IList<Symbol> list = repository.ListAllSymbols<Symbol>();

            Assert.AreEqual(1,list.Count);
            Assert.AreEqual("RELTICK",list[0].Value);
        }
Example #3
0
        public void TestLookupAfterSave()
        {
            var hundredRuppees = new Price(100);
            var relianceMutuals = new Symbol("RELTICK");

            Instrument instrument = new MutualFund(relianceMutuals, hundredRuppees, "Test Fund", "SUNMF", "SUN Magma", "Growth");

            repository.Save(instrument);

            var actual = repository.Lookup<Instrument>(instrument.Id);

            Assert.AreEqual(typeof(MutualFund), actual.GetType());

            Instrument expectedMutualFund = new MutualFund(relianceMutuals, hundredRuppees, "Test Fund", "SUNMF", "SUN Magma", "Growth")
                                                {Id = actual.Id};
            Assert.AreEqual(expectedMutualFund, actual);
            Assert.AreNotEqual(0, instrument.Id);
            Assert.True(instrument.Id > 0);
        }
Example #4
0
 public Stock(Symbol symbol, Price currentPrice, string description)
     : base(symbol, currentPrice, description)
 {
 }
Example #5
0
 public TermDeposit(Term term, Price investedAmount,
                     Symbol symbol, string description,
                     InterestRate interestRate, int interestPayoutFrequency)
     : base(symbol, investedAmount, description)
 {
     Term = term;
     InterestRate = interestRate;
     InvestedAmount = investedAmount;
     InterestPayoutFrequency = interestPayoutFrequency;
     Validate();
 }
Example #6
0
 public bool Equals(Symbol other)
 {
     if (ReferenceEquals(null, other)) return false;
     if (ReferenceEquals(this, other)) return true;
     return Equals(other.Value, Value);
 }
Example #7
0
        public Price CurrentMarketValue(Symbol symbol)
        {
            Instrument instrument = Repository.LookupBySymbol<Instrument>(symbol);
            IList<Transaction> list = Repository.ListTransactionsByInstrumentId<Transaction>(instrument.Id);

            return instrument.CurrentMarketValue(list);
        }
Example #8
0
 public SinglePayOut(Term term, Price investedAmount,
                     Symbol symbol, string description,
                     InterestRate interestRate)
     : base(term, investedAmount, symbol, description, interestRate, 0)
 {
 }
Example #9
0
        public void TestLookupBySymbol()
        {
            var hundredRuppees = new Price(100);
            var relianceMutuals = new Symbol("RELTICK");

            Instrument instrument = new MutualFund(relianceMutuals, hundredRuppees, "Test Fund", "SUNMF", "SUN Magma", "Growth");
            repository.Save(instrument);

            var symbol = new Symbol("RELTICK");
            Instrument resultInstrument = repository.LookupBySymbol<Instrument>(symbol);
            Assert.AreEqual(instrument, resultInstrument);
        }
Example #10
0
        public void TestSave()
        {
            var hundredRuppees = new Price(100);
            var relianceMutuals = new Symbol("RELTICK");

            Instrument instrument = new MutualFund(relianceMutuals, hundredRuppees, "Test Fund", "SUNMF", "SUN Magma", "Growth");

            Assert.AreEqual(0, instrument.Id);
            repository.Save(instrument);
            Assert.AreNotEqual(0, instrument.Id);
            Assert.IsNotNull(instrument.Id);
        }
Example #11
0
 protected Instrument(Symbol symbol, Price price, string description)
 {
     Symbol = symbol;
     CurrentPrice = price;
     Description = description;
 }