public void AddProducer_ThrowsExceptionWhenPassingSameProducerMoreThanOnce()
 {
     SmartWarehouse<FormattedText> warehouse = new SmartWarehouse<FormattedText>(20);
     PasswordDistributor distributor = new PasswordDistributor(warehouse);
     PasswordProducer producer = new PasswordProducer(new FormattedText("abc"));
     distributor.AddProducer(producer);
     Assert.Throws(typeof(ArgumentException), delegate()
     {
         distributor.AddProducer(producer);
     });
 }
 public void AddProducer_ThrowsExceptionWhenPassingNullReference()
 {
     SmartWarehouse<FormattedText> warehouse = new SmartWarehouse<FormattedText>(20);
     PasswordDistributor distributor = new PasswordDistributor(warehouse);
     Assert.Throws(typeof(NullReferenceException), delegate()
     {
         distributor.AddProducer(null);
     });
 }
        static void Main(string[] args)
        {
            SmartWarehouse<FormattedText> warehouse = new SmartWarehouse<FormattedText>(20);
            PasswordProducer pp = new PasswordProducer(new FormattedText("abc"));
            PasswordConsumer pc = new PasswordConsumer(new FormattedText("cba"));

            PasswordDistributor distributor = new PasswordDistributor(warehouse);
            distributor.AddProducer(pp);
            distributor.AddConsumer(pc);
            distributor.StartConsumption();

            PasswordConsumer consumer = new PasswordConsumer(new FormattedText("bca"));
            distributor.AddConsumer(consumer);

            distributor.StartProduction();

            PasswordProducer producer = new PasswordProducer(new FormattedText("abc"));
            distributor.AddProducer(producer);

            Console.ReadLine();
            Console.WriteLine(warehouse.Count);
        }
        public void StartProduction_ThrowsExceptionWhenTryingToCallMethodWhenProductionIsNotStopped()
        {
            SmartWarehouse<FormattedText> warehouse = new SmartWarehouse<FormattedText>(20);
            PasswordDistributor distributor = new PasswordDistributor(warehouse);
            PasswordProducer producer = new PasswordProducer(new FormattedText("abc"));
            producer.PasswordAdditionMaximumTime = 20;
            distributor.AddProducer(producer);

            distributor.StartProduction();
            Assert.Throws(typeof(InvalidOperationException), delegate()
            {
                distributor.StartProduction();
            });
            producer.StopProduction();
        }